2014-10-31 6 views
8

कोई भी Azure AD ग्राफ़ क्लाइंट के नए 2.0 संस्करण का उपयोग कर रहा है?Azure सक्रिय निर्देशिका ग्राफ़ क्लाइंट 2.0

मैंने कल इसके साथ बेवकूफ बनाना शुरू कर दिया लेकिन इसे काम पर नहीं लाया। GraphConnection कक्षा को चिह्नित किया गया है और ActiveDirectoryClient के साथ प्रतिस्थापित किया गया है। इसके अलावा अचानक यह सभी Office 365 है जबकि मैं अपने परीक्षणों को O365 के बिना Azure Active Directory पर सीमित करना चाहता हूं। प्रलेखन मुश्किल है, कम से कम जब आप O365 और O365 API उपकरण का उपयोग नहीं करना चाहते हैं। गिटहब पर एडी नमूने भी अपडेट किए गए प्रतीत होते हैं लेकिन कोड अभी भी GraphConnection कक्षा का उपयोग कर रहा है। जाओ पता लगाओ।

ज्यादा नहीं नमूने/अभी तक ActiveDirectory क्लाइंट का उपयोग पर मार्गदर्शन तो नीचे दिए गए कोड अब

public async Task<ActionResult> Index() 
     { 
      List<Exception> exceptions = new List<Exception>(); 
      ProfileViewModel model = new ProfileViewModel(); 
      string userObjectID = ClaimsPrincipal.Current.FindFirst("http://schemas.microsoft.com/identity/claims/objectidentifier").Value; 
      AuthenticationContext authContext = new AuthenticationContext(SecurityConfiguration.Authority, new NaiveSessionCache(userObjectID)); 
      ClientCredential credential = new ClientCredential(SecurityConfiguration.ClientId, SecurityConfiguration.AppKey); 

      try 
      { 
       var ServiceUri = new Uri(SecurityConfiguration.GraphUrl); 
       ActiveDirectoryClient client = new ActiveDirectoryClient(ServiceUri, async() => 
       { 
        var result = await authContext.AcquireTokenSilentAsync(SecurityConfiguration.GraphUrl, credential, new UserIdentifier(userObjectID, UserIdentifierType.UniqueId)); 

        return result.AccessToken; 
       }); 
       try 
       { 

        var users = await client.Users.ExecuteAsync(); 

        var user = await client.Users[userObjectID].ExecuteAsync(); 


       } 
       catch (Exception exc) 
       { 
        exceptions.Add(exc); 
       } 


      } 
      catch (AdalSilentTokenAcquisitionException exc) 
      { 
       exceptions.Add(exc); 

      } 
      ViewBag.Exceptions = exceptions; 
      return View(model); 
     } 

client.Users.ExecuteAsync() फेंकता अपवाद

The response payload is a not a valid response payload. Please make sure that the top level element is a valid Atom or JSON element or belongs to 'http://schemas.microsoft.com/ado/2007/08/dataservices' namespace. 

client.Users[userObjectID].ExecuteAsync() के लिए उपयोग कर Innerexpection

साथ
Expected a relative URL path without query or fragment. 
Parameter name: entitySetName 
System.Reflection.TargetInvocationException फेंकता

अद्यतन 2/11

डरावना संकल्प: कोड 'क्लाइंट.उसर.एक्सक्यूटएसिंक()' की एक पंक्ति को बदले बिना अपेक्षित के रूप में काम किया। मेरा विचार यह है कि एमएसएफटी के लोगों ने एपीआई पर कुछ सामान बदल दिया ताकि प्रतिक्रिया पेलोड अब सही हो। वे इसका उल्लेख कर सकते थे।

का उपयोग कर उपयोगकर्ता जानकारी प्राप्त करने के लिए v2.0 कोड के नीचे करता है चाल

वर userFetcher = client.Users.Where (यू => u.ObjectId == userObjectID); var उपयोगकर्ता = उपयोगकर्ता का इंतजार करें Fetcher.ExecuteAsync();

आप रेजर का उपयोग कर रहे हैं, तो उपयोगकर्ता आप शायद जब के रूप में अपने web.config में संकलन सेटिंग में बदलाव करने की जाती है इस तरह की तरह AssignedPlans

The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. 

संकल्प संग्रह के माध्यम से जाने की कोशिश कर रहा उस्तरा अपवाद मिल जाएगा की सामग्री प्रदर्शित करने के http://www.lyalin.com/2014/04/25/the-type-system-object-is-defined-in-an-assembly-that-is-not-reference-mvc-pcl-issue/

<compilation debug="true" targetFramework="4.5" > 
     <assemblies> 
     <add assembly="System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> 
     </assemblies> 
    </compilation> 
+0

हमने पाया है एएडी बहुत, बहुत निराशा होती है हाल ही में साथ काम करने के। वर्तमान में हम सभी प्रकार के मुद्दों में चल रहे हैं, विशेष रूप से ज़ूमो के संबंध में, और ब्लॉगों और एसओ की चपेट में समाधान ढूंढ रहे हैं ... आधिकारिक दस्तावेज में कुछ भी नहीं बताया गया है। यदि आप एमएस के ट्यूटोरियल का पालन नहीं कर रहे हैं, तो आप जंगली हंस चेस के लिए हैं। –

उत्तर

0

में उल्लिखित बजाय आईडी द्वारा एक उपयोगकर्ता इकाई को पुन: प्राप्त, के लिए:

var userFetcher = client.Users.Where(u => u.ObjectId == userObjectID); 
var user = await userFetcher.ExecuteAsync(); 

तुम सिर्फ getByObjectId सीधे उपयोग कर सकते हैं:

var user = await client.Users.GetByObjectId(userObjectID).ExecuteAsync(); 
संबंधित मुद्दे