【发布时间】:2018-06-12 18:39:18
【问题描述】:
我需要使用新的自定义属性更新特定用户 ldap。运行时抛出异常“未处理的异常:System.DirectoryServices.DirectoryServicesCOMException:指定的目录服务属性或值不存在”。我的代码是:
using (var entryRoot = new DirectoryEntry("LDAP://ldap.com:389/OU=CATALOG,DC=ldap,DC=com", "juan", "juan2016", AuthenticationTypes.Secure)){
DirectorySearcher user_searcher = new DirectorySearcher(entryRoot);
user_searcher.Filter = $"(&(objectCategory=person)(objectClass=user)(samAccountName={cn1}))"
user_searcher.PropertiesToLoad.Add("identification");
SearchResultCollection result = user_searcher.FindAll();
DirectoryEntry user_ldap = result[0].GetDirectoryEntry();
user_ldap.Properties["identification"].Value = identification;
user_ldap.CommitChanges();
}
【问题讨论】:
-
似乎您需要先将属性添加到用户,然后再尝试将其设置为...
-
您是否手动将
identification属性添加到您的架构中?它不是开箱即用的有效属性。
标签: c# active-directory ldap