1LDAP_OPEN(3)               Library Functions Manual               LDAP_OPEN(3)
2
3
4

NAME

6       ldap_init,  ldap_open  - Initialize the LDAP library and open a connec‐
7       tion to an LDAP server
8

LIBRARY

10       OpenLDAP LDAP (libldap, -lldap)
11

SYNOPSIS

13       #include <ldap.h>
14
15       LDAP *ldap_open(host, port)
16       char *host;
17       int port;
18
19       LDAP *ldap_init(host, port)
20       char *host;
21       int port;
22

DESCRIPTION

24       ldap_open() opens a connection to an LDAP server and allocates an  LDAP
25       structure which is used to identify the connection and to maintain per-
26       connection information.  ldap_init() allocates an  LDAP  structure  but
27       does not open an initial connection.  One of these two routines must be
28       called before any operations are attempted.
29
30       ldap_open() takes host, the hostname on which the LDAP server  is  run‐
31       ning,  and  port,  the port number to which to connect.  If the default
32       IANA-assigned port of 389 is desired, LDAP_PORT should be specified for
33       port.   The  host parameter may contain a blank-separated list of hosts
34       to try to connect to, and each host  may  optionally  by  of  the  form
35       host:port.   If  present,  the  :port  overrides  the port parameter to
36       ldap_open().  Upon successfully making a connection to an LDAP  server,
37       ldap_open()  returns  a  pointer  to an LDAP structure (defined below),
38       which  should  be  passed   to   subsequent   calls   to   ldap_bind(),
39       ldap_search(),  etc. Certain fields in the LDAP structure can be set to
40       indicate size limit, time limit, and how  aliases  are  handled  during
41       operations.  See <ldap.h> for more details.
42
43            typedef struct ldap {
44                 /* ... other stuff you should not mess with ... */
45                 char      ld_lberoptions;
46                 int       ld_deref;
47            #define LDAP_DEREF_NEVER 0
48            #define LDAP_DEREF_SEARCHING  1
49            #define LDAP_DEREF_FINDING    2
50            #define LDAP_DEREF_ALWAYS     3
51                 int       ld_timelimit;
52                 int       ld_sizelimit;
53            #define LDAP_NO_LIMIT         0
54                 int       ld_errno;
55                 char      *ld_error;
56                 char      *ld_matched;
57                 int       ld_refhoplimit;
58                 unsigned long  ld_options;
59            #define LDAP_OPT_REFERRALS      0x00000002 /* set by default */
60            #define LDAP_OPT_RESTART 0x00000004
61                 /* ... other stuff you should not mess with ... */
62            } LDAP;
63
64       ldap_init()  acts just like ldap_open(), but does not open a connection
65       to the LDAP server.  The actual connection open  will  occur  when  the
66       first  operation is attempted.  At this time, ldap_init() is preferred.
67       ldap_open() will be depreciated in a later release.
68

ERRORS

70       If an error occurs, these routines will return NULL and errno should be
71       set appropriately.
72

OPTIONS

74       Options  that affect a particular LDAP instance may be set by modifying
75       the ld_options field in the LDAP  structure.   This  field  is  set  to
76       LDAP_OPT_REFERRALS  in  ldap_open()  and  ldap_init(), which causes the
77       library to automatically follow referrals to other servers that may  be
78       returned in response to an LDAP operation.
79
80       The other supported option is LDAP_OPT_RESTART, which if set will cause
81       the LDAP library to restart the select(2) system call when it is inter‐
82       rupted by the system (i.e., errno is set to EINTR).  This option is not
83       supported on the Macintosh and under MS-DOS.
84
85       An option can be turned off by clearing  the  appropriate  bit  in  the
86       ld_options field.
87

NOTES

89       There  are  other  elements  in  the LDAP structure that you should not
90       change. You should not make any assumptions about the order of elements
91       in the LDAP structure.
92

SEE ALSO

94       ldap(3), ldap_bind(3), errno(3)
95

ACKNOWLEDGEMENTS

97       OpenLDAP   is   developed   and  maintained  by  The  OpenLDAP  Project
98       (http://www.openldap.org/).  OpenLDAP is  derived  from  University  of
99       Michigan LDAP 3.3 Release.
100
101
102
103OpenLDAP 2.3.34                    2007/2/16                      LDAP_OPEN(3)
Impressum