Click here to Skip to main content
15,889,810 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i am trying to get the license details of each user on my azure tenant on this webapp and i want to provide an edit option like the one you find in office 365 for user licenses how can i do this right?

my details.cshtml page

C++
<tr>
<td>
                        <div class="display-label">
                            @Html.DisplayNameFor(model => model.AssignedLicenses)
                        </div>
                    </td>
                    <td>
                        <div class="display-field">
                            @Html.DisplayFor(model => model.AssignedLicenses)
                        </div>
                    </td>
                </tr>



I am displaying the license in a table

my details controller code


C#
public async Task<ActionResult> Details(string objectId)    ///details method
    {
        User user = null;
        try    /// authenticate and wait to get details 
        {
            ActiveDirectoryClient client = AuthenticationHelper.GetActiveDirectoryClient();  
            user = (User)await client.Users.GetByObjectId(objectId).ExecuteAsync();
        }
        catch (Exception ex)
        {
            if (Request.QueryString["reauth"] == "True")
            {
                //
                // Send an OpenID Connect sign-in request to get a new set of tokens.
                // If the user still has a valid session with Azure AD, they will not be prompted for their credentials.
                // The OpenID Connect middleware will return to this controller after the sign-in response has been handled.
                //
                HttpContext.GetOwinContext()
                    .Authentication.Challenge(OpenIdConnectAuthenticationDefaults.AuthenticationType);
            }





            ViewBag.ErrorMessage = "AuthorizationRequired";
            Logger.Error(ex);
            return View(user);
        }

        return View(user);  
    }


What I have tried:

I am using @Html.DisplayFor(model => model.AssignedLicenses) statement but obviously it shows this " Microsoft.Azure.ActiveDirectory.GraphClient.Extensions.NonEntityTypeCollectionImpl`1[System.Guid] " instead. So how can I view the assigned licenses to the user and edit them
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900