LDAP异常对象类违规:添加新用户

时间:2014-03-11 00:01:21

标签: c# c#-4.0 ldap

我正在尝试在LDAP目录中创建用户,但是我收到以下错误:“Object Class Violation”。有人可以提出解决方案吗?

try             
{
    DirectoryEntry ouEntry = new DirectoryEntry("LDAP://localhost:389/ou=people,dc=wso2,dc=com","cn=admin,dc=wso2,dc=com", "toto", AuthenticationTypes.Secure);

    DirectoryEntry childEntry = ouEntry.Children.Add("CN=tati toto", "inetOrgPerson");
    childEntry.Properties["sn"].Add("toto");
    childEntry.CommitChanges();
}
catch(Exception Ex)             
{
    Console.WriteLine("Exception : "+ Ex.Message);
}

1 个答案:

答案 0 :(得分:0)

我解决了,

 try             
 {
DirectoryEntry ouEntry = new DirectoryEntry("LDAP://localhost:389/ou=people,dc=wso2,dc=com","cn=admin,dc=wso2,dc=com", "toto", AuthenticationTypes.Secure);

DirectoryEntry childEntry = ouEntry.Children.Add("CN=tati toto", "top");
childEntry.Properties["objectclass"].Add("person");
childEntry.Properties["sn"].Add("toto");
childEntry.CommitChanges();
 }
 catch(Exception Ex)             
{
Console.WriteLine("Exception : "+ Ex.Message);
}