【问题标题】:Update user with new custom attribute C# LDAP使用新的自定义属性 C# LDAP 更新用户
【发布时间】: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


【解决方案1】:

在“Active Directory Schema”中添加海关属性并作为可选属性分配给用户类,在运行我的代码和成功结果后

【讨论】:

    猜你喜欢
    • 2020-12-22
    • 2012-11-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-09
    • 1970-01-01
    • 2019-03-25
    相关资源
    最近更新 更多