[英]Update user with new custom attribute C# LDAP
我需要使用新的自定義屬性更新特定的用戶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();
}
運行我的代碼並獲得成功的結果后,在“ Active Directory架構”中添加海關屬性,並分配給用戶類作為可選屬性
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.