ldap_add — Adds a new entry to an LDAP directory.


int ldap_add ( in server_url varchar ,
in try_tls integer ,
in data varchar ,
in username varchar ,
in password varchar );


This function adds a new entry to the LDAP directory.



The server URL has three parts, <protocol>://<host>:<port>. Missing parameters will be defaulted to:




try_tls is a flag that tells the client to perform a handshake with the LDAP server using a secure connection. This is only applicable to the ldap:// protocol and not ldaps://. If the secure connection attempt fails, the client will fall back to insecure connect.


data is an array with name/value pairs representing the data to be added.


username authorization credential


password authorization credential

Return Types

The error status code is returned. Zero for success.


Table24.49.Errors signalled by ldap_add

SQLState Error Code Error Text Description
2E000 LD005 Failed to initialize LDAP connection: <reason> (<reason code>)
2E000 LD006 Failed to set LDAP version option: <reason> (<reason code>)
2E000 LD016 Failed to start TLS: <reason> (<reason code>)
28000 LD007 Failed to bind synchronous LDAP connection: <reason> (<reason code>)
2E000 LD004 The DN must be supplied
2E000 LD004 Failed to modify err=<reason code (<reason>)


Example24.203.Using ldap_add

create procedure
sam_ldap_add (in s1 varchar, in s2 varchar)
  declare res, vec any;
  declare _from_add integer;

  vec := vector ('dn', concat ('cn=', s1, ' ', s2, ',o=opl,c=BG'),
         'cn', vector (concat (s1, ' ', s2)),
         'mail', vector(''),
         'sn', vector(s2), 'telephoneNumber', vector('032-947020', '032-633710', '048 850 760'),
         'objectClass', vector('inetorgperson' ));

  _from_add := ldap_add ('ldap://buba:389', 0, vec, NULL);

  return (_from_add);