active-directoryldapopenldapapachedsldapjs

Is it possible to create entry into LDAP server without RDN with only attributes?


We are using ldapjs node module to communicate with LDAP servers like Microsoft Active Directory, Apache DS and Open LDAP. As per our understanding from here:

DNs can be comprised of zero or more components, which means that it is legal to have a DN without any components at all.

Is it possible to create entry into LDAP server with only attributes without any RDN in my Base DN?

For example, if I wanted to create inetOrgPerson entry into LDAP server without RDN, creating entry as below:

var ldap = require('ldapjs');
var client = ldap.createClient({  
  url: 'ldap://xxxxxxxx:389'
});
client.bind('xxxxxxxx', 'xxxxxxxxx', function(err) {
  if(err){
      console.log('error',err);
  }else{
      console.log('bind is success');
  }
});

var newDN = "ou=testou,dc=xxxx,dc=com";
var newUser = {    
    objectClass: 'inetOrgPerson',
    sn: 'test'
  }

client.add(newDN, newUser, function(err) {  
  if(err){
      console.log('error',err);
  }else{     
      client.unbind(function(err) {
          if(err){
              console.log('error unbind : ',err);
          }else{
              console.log('unbind is success');
          }
        });
  }
})

After executing above code there should be entry in the OU testou with sn as test. Any inputs will help. Thank you all.


Solution

  • While it is legal to have a DN with zero component, it is reserved for the rootDSE. It is mandatory for any entry to have a non-empty DN, and therefore to have a non-empty RDN.