如果我的服务器中有一个Active设置,其域为"mydomain.com",我将为此创建LDAP DirectorySearcher,如下所示。
string domainPath = "LDAP://mydomain.com";
DirectoryEntry entry = new DirectoryEntry(domainPath, "userName", "password");
DirectorySearcher searcher = new DirectorySearcher(entry);如果我想为我的Office365ActiveDirectory创建DirectorySearcher,那么DirectorySearcher将是什么?
P.S :我已经用'AzureADSync‘与Office 365同步了服务器的Active
发布于 2016-08-06 21:16:32
LDAP仅适用于现场活动目录.
对于Azure Active,您需要使用图形API( Microsoft图或Azure图 )。请参阅此链接以了解如何在其中一种和另一种之间进行选择)
您需要注册应用程序,根据需要设置正确的权限,并具有类似于以下代码段的代码:
注意:这个特定的代码段返回目录中的所有用户:
var authority = "https://login.microsoftonline.com/";
var resource = "https://graph.windows.net/";
var tenant = "mydomain.com";
var clientId = <YourClientID>;
var redirectUri = <YourRedirectUri>;
var ctx = new AuthenticationContext(authority + tenant);
var graphUri = resource + tenant;
var client = new ActiveDirectoryClient(new Uri(graphUri),
async () => {
var token = await ctx.AcquireTokenAsync(resource, clientId, new Uri(redirectUri), new PlatformParameters(PromptBehavior.Always));
return token.AccessToken;
});
var users = await client.Users.ExecuteAsync();
users.CurrentPage.Select(u => u.DisplayName).Dump();这是一个指向Azure AD图示例的链接。其中包含关于应用程序注册、设置权限以及如何从不同平台/场景查询图表的说明。
https://stackoverflow.com/questions/38726555
复制相似问题