Add Method

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

Syntax

ANSI (Cross Platform)
int Add();

Unicode (Windows)
INT Add();
- (void)add;
#define MID_LDAP_ADD 3

IPWORKSAUTH_EXTERNAL int IPWORKSAUTH_CALL IPWorksAuth_LDAP_Do(void *lpObj, int methid, int cparam, void *param[], int cbparam[], int64 *lpllVal);

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()

Error Handling (C++)

This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks Auth 2020 C++ Edition - Version 20.0 [Build 8155]