小编Jar*_*rmo的帖子

C#如何向具有多个对象类的LDAP添加条目

我正在尝试使用对象类personuidObject在OpenLDAP中创建一个新的用户记录.问题似乎是使用System.DirectoryServices.DirectoryEntry我发现只有一种方法可以添加一个具有一个对象类的新条目,但不能添加多个对象类.

这个C#代码

DirectoryEntry nRoot = new DirectoryEntry(path);
nRoot.AuthenticationType = AuthenticationTypes.None;
nRoot.Username = username;
nRoot.Password = pwd;

try
{
    DirectoryEntry newUser = nRoot.Children.Add("CN=" + "test", "person");
    newUser.Properties["cn"].Add("test");
    newUser.Properties["sn"].Add("test");
    newUser.Properties["objectClass"].Add("uidObject"); // this doesnt't make a difference
    newUser.Properties["uid"].Add("testlogin"); // this causes trouble
    newUser.CommitChanges();
}
catch (COMException ex)
{
    Console.WriteLine(ex.ErrorCode + "\t" + ex.Message);
}
Run Code Online (Sandbox Code Playgroud)

...导致错误:

-2147016684请求的操作不满足与对象类关联的一个或多个约束.(HRESULT异常:0x80072014)

c# ldap openldap

5
推荐指数
1
解决办法
6072
查看次数

标签 统计

c# ×1

ldap ×1

openldap ×1