# 22. Virtuoso Functions Guide - ldap_add

Chapter Contents | Prev | Next
Keyword Search:
www.openlinksw.com
docs.openlinksw.com
Book Home
Contents
Preface
Virtuoso Functions Guide
Administration
Aggregate Functions
Array Manipulation
BPEL APIs
Backup
Compression
Cursor
Date & Time Manipulation
Debug
Dictionary Manipulation
Encoding & Decoding
File Manipulation
Free Text
Hashing / Cryptographic
LDAP
ldap_add
ldap_delete
ldap_modify
ldap_search
Locale
Mail
Miscellaneous
Number
Remote SQL Data Source
Replication
SOAP
SQL
String
Transaction
Type Mapping
UDDI
User Defined Types & The CLR
Virtuoso Java PL API
Virtuoso Server Extension Interface (VSEI)
Web Server & Internet
XML
XPATH & XQUERY
Functions Index

## 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);
Description

This function adds a new entry to the LDAP directory.

Parameters
server_url – The server URL has three parts, <protocol>://<host>:<port>. Missing parameters will be defaulted to: <ldap://localhost:389>.
try_tls – 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 – data is an array with name/value pairs representing the data to be added.
username – username authorization credential
password – password authorization credential
Return Types

The error status code is returned. Zero for success.

Errors

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

Examples

    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('mail@techno-link.com'),
             '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);
    };

See Also

ldap_delete(), ldap_modify(), ldap_search()