Renaming an existing entry in the directory gives an error saying "Naming Violation"

1.8k Views Asked by At

I'm using Novell in asp.net core 2.2 application to interact with AD. Following functions are working as expected.

  • Getting all users, Getting users from specific OU
  • Create an User
  • Update an User
  • Reset password and etc

But when i try to move the entry to new container it gives following exception

  • Naming Violation
  • ((Novell.Directory.Ldap.LdapException)e).LdapErrorMessage : "00000057: LdapErr: DSID-0C090E72, comment: Error in attribute conversion operation, data 0, v4563"

Here is the code block i'm using.

var dn = $"CN={user.FirstName} {user.LastName},{this._ldapSettings.ContainerName}"; 
    //dn => CN=arshath shameer,CN=Users,DC=wxyzdev,DC=xyzdev,DC=ca
var newRDn = $"CN={user.FirstName} {user.LastName},OU=DeletedUsers,DC=wxyzdev,DC=xyzdev,DC=ca";
    // newRDn =>  CN=arshath shameer,OU=DeletedUsers,DC=wxyzdev,DC=xyzdev,DC=ca

                using (var ldapConnection = this.GetConnection())
                {
                    //ldapConnection.Delete(dn);
                    ldapConnection.Rename(dn, newRDn, dn, true);
                }

I'm following this link.

2

There are 2 best solutions below

0
EricLavault On BEST ANSWER

There are 2 issues to fix :

  • RDN means relative DN : the part in the DN that actually makes an entry distinguishable from others in the same container, for example : CN=arshath shameer in CN=arshath shameer,CN=Users,DC=wxyzdev,DC=xyzdev,DC=ca. In your case, since you don't want to rename but to move an entry, it doesn't change :

    var newRDn = $"CN={user.FirstName} {user.LastName}";
    
  • When moving an entry - contrary to renaming - the RDN stays the same, but the parentDN changes :

    var parentDN = "OU=DeletedUsers,DC=wxyzdev,DC=xyzdev,DC=ca";
    

Now let's move the entry :

ldapConnection.Rename(dn, newRDN, parentDN, true);

You may also need to check whether {this._ldapSettings.ContainerName} is replaced with CN=Users,DC=wxyzdev,DC=xyzdev,DC=ca to ensure dn variable is correctly set.

0
Fazlur Shaikh On



I had encountered this issue.
Having come across this thread from google, it was not clear to use "CN=arshath shameer".

Please use "CN=arshath shameer" instead of "CN=arshath shameer,CN=Users,DC=wxyzdev,DC=xyzdev,DC=ca" in the newRDN parameter.

Thanx.
FRS.