Quantcast
Channel: Azure Active Directory forum
Viewing all articles
Browse latest Browse all 16000

Getting extended properties doesnt work

$
0
0

I have the following code to create extended properties

  public ActionResult CreateProperty()
        {
            // Create the extension property
            string extPropertyName = "Comasdasa3dsdaspInfo";
            ExtensionProperty extensionProperty = new ExtensionProperty()
            {
                Name = extPropertyName,
                DataType = "String",
                TargetObjects = { "User" }
            };
            Uri serviceRoot = new Uri(azureAdGraphApiEndPoint);

            ActiveDirectoryClient adClient = new ActiveDirectoryClient(
             serviceRoot,
             async () => await GetAppTokenAsync());

            Microsoft.Azure.ActiveDirectory.GraphClient.Application app =(Microsoft.Azure.ActiveDirectory.GraphClient.Application)adClient.Applications.Where(
                a => a.AppId == clientId).ExecuteSingleAsync().Result;
            if (app == null)
            {
                throw new ApplicationException("Unable to get a reference to application in Azure AD.");
            }

            // Register the extension property
            app.ExtensionProperties.Add(extensionProperty);
            app.UpdateAsync();
            Task.WaitAll();

            // Apply the change to Azure AD
            //app.GetContext().SaveChanges();
            ViewBag.Message = "Extension Created.";

            return View();
        }

and I have the following code to get the extended properties

   public ActionResult GetProperties()
        {
            Uri serviceRoot = new Uri(azureAdGraphApiEndPoint);

            ActiveDirectoryClient adClient = new ActiveDirectoryClient(
             serviceRoot,
             async () => await GetAppTokenAsync());

            string extPropertyName = "Comasdasa3dsdaspInfo";

            // Locate the vehicle info property extension (workaround)
            string extPropLookupName = string.Format("extension_{0}_{1}", clientId.Replace("-", ""), extPropertyName);
            IEnumerable<IExtensionProperty> allExtProperties = adClient.GetAvailableExtensionPropertiesAsync(false).Result;
            IExtensionProperty vehInfoExtProperty = allExtProperties.Where(
                extProp => extProp.Name == extPropLookupName).FirstOrDefault();

            return View();
        }

Howeever the line GetAvailableExtensionPropertiesAsync never returns, stays there forever without any result.


Follow me on Twitter
levalencia Blog


Viewing all articles
Browse latest Browse all 16000

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>