Add Method

Adds an entry specified by DN to the directory server using the type and value attributes defined in the Attributes properties.

Syntax

ldap.add([callback])

Callback

The 'callback' parameter specifies a function which will be called when the operation completes (or an error is encountered). If the 'callback' parameter is not specified, then the method will block and will not return until the operation completes (or an error is encountered).

The callback for this method is defined as:

function(err){ }

'err' is the error that occurred. If there was no error, then 'err' is 'null'.

'err' has 2 properties which hold detailed information:

err.code
err.message

Remarks

This method adds the entry specified by DN to the directory. All Entries are required to have an objectClass attribute.

In order to add a new entry, first Bind with credentials that will allow you to perform the new addition. To add attributes instead of entries, use the Modify method instead. When specifying multi-valued attributes, specify the attribute type only in the first occurrence of that attribute type in the Attributes properties. Additional occurrences of the same attribute type should specify an attribute type of empty string.

The result of the operation is returned via the Result event.

Example (Add a New Entry, including the multi-valued objectClass attribute)


LDAPControl.DN = "uid=NewUser,ou=Employees,dc=server"
LDAPControl.AttributeCount = 7
LDAPControl.AttributeType(0) = "objectClass"
LDAPControl.AttributeValue(0) = "top"
LDAPControl.AttributeType(1) = ""
LDAPControl.AttributeValue(1) = "person"
LDAPControl.AttributeType(2) = ""
LDAPControl.AttributeValue(2) = "organizationalPerson"
LDAPControl.AttributeType(3) = ""
LDAPControl.AttributeValue(3) = "inetOrgPerson"
LDAPControl.AttributeType(4) = "sn"
LDAPControl.AttributeValue(4) = "UserName"
LDAPControl.AttributeType(5) = "cn"
LDAPControl.AttributeValue(5) = "New S. UserName"
LDAPControl.AttributeType(6) = "uid"
LDAPControl.AttributeValue(6) = "NewUser"
LDAPControl.Add()

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks 2020 Node.js Edition - Version 20.0 [Build 8307]