c# - Azure LDAP 与 DirectoryEntry "the server is not operational"错误 C#

标签 c# .net azure active-directory azure-active-directory

我使用以下教程在 Windows Azure 中配置了安全 LDAP:

https://azure.microsoft.com/en-us/documentation/articles/active-directory-ds-admin-guide-configure-secure-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/

相关文章:

C#用户控件崩溃VS11

c# - 在 SQL Server 2008 R2 Express 中使用 ServiceStack.OrmLite 的 Unicode 字符串

c# - 如何在没有 NoWrap 的情况下跟踪 TextBox 中文本的结尾?

azure - 如何让 Azure 中的 Web 应用程序可以通过 https 访问?

angularjs - 将 Web 应用程序部署到 azure 时出现授权错误

C# 从 StringBuilder 的开头提取数据

c# - “抽象类”与可重用库的 'normal class'

c# - 具体类如何隐藏它实现的接口(interface)的成员

c# - 从 DotNetNuke 中的 FileId 生成 URL

azure - 具有状态参与者的地理映射