我正在使用System.DirectoryServices
库来查询LDAP目录。我看到所有文本属性都很好,但我需要检索一些操作属性,如pwdChangedTime
。尝试获取这些属性时,我得到的对象未设置为对象的类型错误实例。LDAP查询操作属性
using (DirectorySearcher search = new DirectorySearcher(dirCon,
ldapSearchFilter.Replace("{cn}", cn),
new string[] {"*","+"},
SearchScope.Subtree))
{
foreach (SearchResult sr in search.FindAll())
{
la = new LdapAccount();
la.pswdUpdateTime = DateTime.ParseExact(sr.GetDirectoryEntry().Properties["pwdchangedtime"].ToString(), dateFormat, null);
...
}
我看到所有的文本属性,但它不会找到任何操作属性。
@marc_s LDAP实际上是相当* unpicky *的情况下,特别是在属性名称。 – EJP