我使用以下教程在 Windows Azure 中配置了安全 LDAP:
但我收到“服务器无法运行”错误。我正在尝试使用以下代码:
string DomainPath = "LDAP://0.0.0.0:636";
DirectoryEntry searchRoot = new DirectoryEntry(DomainPath, "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6c1f0301090302092c09140d011c0009420f0301" rel="noreferrer noopener nofollow">[email protected]</a>", "password", AuthenticationTypes.Secure);
DirectorySearcher search = new DirectorySearcher(searchRoot);
search.Filter = "(&(objectClass=user)(objectCategory=person))";
search.PropertiesToLoad.Add("samaccountname");
search.PropertiesToLoad.Add("mail");
search.PropertiesToLoad.Add("usergroup");
search.PropertiesToLoad.Add("displayname");//first name
SearchResult result;
SearchResultCollection resultCol = search.FindAll();
if (resultCol != null)
{
for (int counter = 0; counter < resultCol.Count; counter++)
{
string UserNameEmailString = string.Empty;
result = resultCol[counter];
if (result.Properties.Contains("samaccountname") && result.Properties.Contains("mail") &&
result.Properties.Contains("displayname"))
{
Users objSurveyUsers = new Users();
objSurveyUsers.Email = (String)result.Properties["mail"][0] +
"^" + (String)result.Properties["displayname"][0];
objSurveyUsers.UserName = (String)result.Properties["samaccountname"][0];
objSurveyUsers.DisplayName = (String)result.Properties["displayname"][0];
lstADUsers.Add(objSurveyUsers);
}
}
}
我还尝试在 ldp.exe 软件中连接我的 Ip 和域,但也出现连接失败的错误。
我的问题是我可以在azure平台中使用DirectoryEntry来获取用户吗?
如果不是,Azure 中 LDAP 的用途是什么?
提前致谢
最佳答案
在 Azure 上,从 Azure AD 获取用户的最佳实践方式是使用 Azure AD Graph API,请参阅 overview来了解它。
有两种使用 AAD Graph API 的方法,其中包括 REST & SDK .
作为引用,有一篇文章介绍了如何使用Graph API对用户进行操作,并提供了不同编程语言的示例代码,请参见https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/users-operations .
关于c# - Azure LDAP 与 DirectoryEntry "the server is not operational"错误 C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38380995/