如何在其他租户的

时间:2017-09-15 09:48:26

标签: c# azure-active-directory angular2-services azure-ad-graph-api

我已实施多租户应用。现在我想限制其他租户中的一些群组。

例如:我的租客aaaaaaa.com。其他租户xxxxxxxxxxxxx.com

所以我想得到" xxxxxxxxxx.COM"用户组信息以及C#中的用户信息。

我已经尝试使用GraphApi获取其他租户和我的租户用户信息和群组信息。但我没有得到解决方案。我尝试如下

        // These are the credentials the application will present during authentication
    // and were retrieved from the Azure Management Portal.
    // *** Don't even try to use these - they have been deleted.
    const string clientID = "xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx";
    const string clientSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";

    // The Azure AD Graph API is the "resource" we're going to request access to.
    const string resAzureGraphAPI = "https://graph.windows.net";

    // The Azure AD Graph API for my directory is available at this URL.
    const string serviceRootURL = "https://graph.windows.net/xxxxxxxxxxxxxxx";

    public async Task<User> userExists()
    {
        Uri serviceRoot = new Uri(serviceRootURL);
        Microsoft.Azure.ActiveDirectory.GraphClient.ActiveDirectoryClient adClient = new ActiveDirectoryClient(
            serviceRoot,
            async () => await GetAppTokenAsync());
        // Look up a user in the directory by their UPN.
        var upn = "srikanth@xxxxxx.onmicrosoft.com";
        var userLookupTask = await adClient.Users.Where(
            user => user.UserPrincipalName.Equals(
                upn, StringComparison.CurrentCultureIgnoreCase)).ExecuteSingleAsync();
        Thread.Sleep(30000);
        User Userdata = (User)userLookupTask;

        // Show John Doe's Name
        Console.WriteLine(Userdata.DisplayName);
        return userJohnDoe;
    }

任何回答都表示赞赏。

先谢谢........!

0 个答案:

没有答案
相关问题