LDAP读取扩展属性的问题

TTLOVEYOU3344 2009-12-02 01:34:27
各位大虾:
我今天在读服务器上LDAP数据的时候遇到了麻烦,我无法读取LDAP上的扩展属性,我的代码如下:

public void ReadLdapUser(string ipAddress, string ldapUsername, string ldapPassword)
{
string subpathformat = "LDAP://{0}/o=sdf";
string subpath = String.Format(subpathformat, ipAddress);
DirectoryEntry entry = new DirectoryEntry(subpath,ldapUsername,ldapPassword);
entry.AuthenticationType = AuthenticationTypes.Anonymous;
DirectorySearcher mySearcher = new DirectorySearcher(entry);
foreach (System.DirectoryServices.SearchResult resEnt in mySearcher.FindAll())
{
DirectoryEntry de = resEnt.GetDirectoryEntry();
if (de.Properties.Count >= 20)
{
foreach (string elmentName in de.Properties.PropertyNames)
{
PropertyValueCollection valueCollection = de.Properties[elmentName];//这里一遇到扩展属性的名字一读就报异常,{"未知错误(0x8000500c)"}
for (int i = 0; i < valueCollection.Count; i++)
{
string kkk = valueCollection[i].ToString();
MessageBox.Show(kkk);
}
}
if (de.SchemaClassName.ToString() == "inetOrgPerson")
{
string userGuid = Guid.NewGuid().ToString();
}
}
}

}

我的目的是要把LDAP上所有的用户数据读出来插入到我的数据库里,同时根据扩展字段职位来给这些用户分配权限
...全文
204 回复 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

111,094

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧