[英]Update user with new custom attribute C# LDAP
I need update a specific user ldap with new custom attributes. 我需要使用新的自定义属性更新特定的用户ldap。 When run throw Exception "Unhandled Exception: System.DirectoryServices.DirectoryServicesCOMException: The specified directory service attribute or value does not exist". 运行时引发异常“未处理的异常:System.DirectoryServices.DirectoryServicesCOMException:指定的目录服务属性或值不存在”。 My code is: 我的代码是:
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();
}
运行我的代码并获得成功的结果后,在“ Active Directory架构”中添加海关属性,并分配给用户类作为可选属性
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.