检索 Active Directory DirectoryEntry 的街道地址属性
我有一个 Active Directory 用户 DirectoryEntries 的集合,我需要获取与每个目录关联的街道地址。我正在使用以下内容:
bool TryGetPropertyValue(DirectoryEntry de, string propertyName, out string propertyValue)
{
if (de.Properties.Contains(propertyName) && de.Properties[propertyName].Count > 0)
{
propertyValue = de.Properties[propertyName][0].ToString();
return true;
}
propertyValue = string.Empty;
return false;
}
但是我找不到可以获取用户地址的 propertyName
值。是否存在,或者是否有另一种方式来获取此信息?
I have a collection of Active Directory user DirectoryEntries and I need to get the street address associated with each. I'm using something along the lines of:
bool TryGetPropertyValue(DirectoryEntry de, string propertyName, out string propertyValue)
{
if (de.Properties.Contains(propertyName) && de.Properties[propertyName].Count > 0)
{
propertyValue = de.Properties[propertyName][0].ToString();
return true;
}
propertyValue = string.Empty;
return false;
}
But I can't find a value of propertyName
that will get the address of the user. Does one exist, or is there another way to get this information?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请注意获取
DirectoryEntry de
的方式。从纯粹的 LDAP 角度来看,最好在目录搜索期间指定您真正想要检索的属性。我知道大多数开发人员都认为所有属性都应该是可检索的,但从 LDAP 的角度来看,情况并不那么明显:从属性名称的角度来看,您最好参考 Active Directory 架构和专业所有属性。
为了将属性与用户和计算机 Active-Directory MMC 中的输入字段链接起来,您可以使用 LDP.EXE(W2K8 中固有的,来自 W2K3 中的资源工具包)。另一个有趣的工具是 Apache Directory Studio。它适用于所有平台(Linux (MAC)、Microsoft),并允许您浏览目录和架构。
Be careful of the way you get
DirectoryEntry de
. On pure LDAP point of view, it's better to specify during a directory search the attributes that you really want to retreive. I know that most of developpers suppose that all attributes should be retreive, but on the LDAP point of view it's not so evident :On the attributes names point of view you'd better refer to Active Directory Schema and specialy All atributes.
In order to link an attribute with an entry field in the user and computer Active-Directory MMC you can use LDP.EXE (which is native in W2K8, and come from the ressource kit in W2K3). Another interesting tool is Apache Directory Studio. It works on all plateforms (Linux (MAC), Microsoft) and allow you to browse the Directory and the Schema.