1ldap_open(3LDAP)            LDAP Library Functions            ldap_open(3LDAP)
2
3
4

NAME

6       ldap_open, ldap_init - initialize an LDAP session
7

SYNOPSIS

9       cc [ flag... ] file... -lldap [ library... ]
10       #include <lber.h>
11       #include <ldap.h>
12
13       LDAP *ldap_open(const char *host, int port);
14
15
16       LDAP *ldap_init(const char *host, int port);
17
18

DESCRIPTION

20       The  ldap_open()  function initializes an LDAP session and also opens a
21       connection to an LDAP server before it returns to  the  caller.  Unlike
22       ldap_open(),  ldap_init() does not open a connection to the LDAP server
23       until an operation, such as a search request, is performed.
24
25
26       The ldap_open() function is deprecated and should no  longer  be  used.
27       Call ldap_init() instead.
28
29
30       A  list  of  LDAP hostnames or an IPv4 or IPv6 address can be specified
31       with the  ldap_open()  and  ldap_init()  functions.  The  hostname  can
32       include  a  port  number, separated from the hostname by a colon (:). A
33       port number included as part of the hostname takes precedence over  the
34       port  parameter. The ldap_open() and ldap_init() functions attempt con‐
35       nections with LDAP hosts in the order listed and return the first  suc‐
36       cessful connection.
37

PARAMETERS

39       These functions support the following parameters.
40
41       host    The  hostname,  IPv4  or IPv6 address of the host that runs the
42               LDAP server. A space-separated list of hostnames  can  also  be
43               used for this parameter.
44
45
46       port    TCP  port number of a connection. Supply the constant LDAP_PORT
47               to obtain the default LDAP port of 389. If a  host  includes  a
48               port number, the default parameter is ignored.
49
50

RETURN VALUES

52       The  ldap_open()  and  ldap_init() functions return a handle to an LDAP
53       session that contains a pointer to an opaque structure.  The  structure
54       must be passed to subsequent calls for the session. If a session cannot
55       be initialized, the functions return  NULL  and  errno  should  be  set
56       appropriately.
57
58
59       Various aspects of this opaque structure can be read or written to con‐
60       trol the session-wide parameters.  Use  the  ldap_get_option(3LDAP)  to
61       access  the current option values and the ldap_set_option(3LDAP) to set
62       values for these options.
63

EXAMPLES

65       Example 1 Specifying IPv4 and IPv6 Addresses
66
67
68       LDAP  sessions  can  be  initialized  with  hostnames,  IPv4  or   IPv6
69       addresses, such as those shown in the following examples.
70
71
72         ldap_init("hosta:636 hostb", 389)
73         ldap_init("192.168.82.110:389", 389)
74         ldap_init("[fec0::114:a00:20ff:ab3d:83ed]", 389)
75
76
77

ATTRIBUTES

79       See attributes(5) for descriptions of the following attributes:
80
81
82
83
84       ┌─────────────────────────────┬─────────────────────────────┐
85       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
86       ├─────────────────────────────┼─────────────────────────────┤
87       │Interface Stability          │Evolving                     │
88       ├─────────────────────────────┼─────────────────────────────┤
89       │MT-Level                     │Safe                         │
90       └─────────────────────────────┴─────────────────────────────┘
91

SEE ALSO

93       errno(3C),   ldap(3LDAP),   ldap_bind(3LDAP),   ldap_get_option(3LDAP),
94       ldap_set_option(3LDAP), attributes(5)
95
96
97
98SunOS 5.11                        15 Jan 2004                 ldap_open(3LDAP)
Impressum