Я пытаюсь использовать службы каталогов для добавления записи каталога на сервер openldap. Примеры, которые я видел, выглядят довольно просто, но я получаю сообщение об ошибке «Нарушение именования». Что означает это сообщение? Как мне решить это?
Я включил код, файл ldif, используемый для создания контейнера person.
Public Function Ldap_Store_Manual_Registration(ByVal userName As String, ByVal firstMiddleName As String, ByVal lastName As String, ByVal password As String)
Dim entry As DirectoryEntry = OpenLDAPconnection() 'OpenLDAPconnection() is DirectoryEntry(domainName, userId, password, AuthenticationTypes.SecureSocketsLayer) )
Dim newUser As DirectoryEntry
newUser = entry.Children.Add("ou=alumni", "organizationalUnit") 'also try with newUser = entry.Children.Add("ou=alumni,o=xxxx", "organizationalUnit") , also not working
SetADProperty(newUser, "objectClass", "organizationalPerson")
SetADProperty(newUser, "objectClass", "person")
SetADProperty(newUser, "cn", userName)
SetADProperty(newUser, "sn", userName)
newUser.CommitChanges()
End Function
Public Shared Sub SetADProperty(ByVal de As DirectoryEntry, _
ByVal pName As String, ByVal pValue As String)
'First make sure the property value isnt "nothing"
If Not pValue Is Nothing Then
'Check to see if the DirectoryEntry contains this property already
If de.Properties.Contains(pName) Then 'The DE contains this property
'Update the properties value
de.Properties(pName)(0) = pValue
Else 'Property doesnt exist
'Add the property and set it's value
de.Properties(pName).Add(pValue)
End If
End If
End Sub
Файл ldif:
version: 1
dn: cn=test3,ou=alumni,o=unimelb
objectClass: organizationalPerson
objectClass: person
objectClass: top
cn: test3
sn: test3