1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285
|
/* $Id: LDAP.client,v 1.2 1999/04/10 14:21:10 hop Exp $ */
NAME
LDAP.client - Interface to the Ldap directory
DESCRIPTION
LDAP.client is a Pike module. It enables
access to the Ldap directory from within Pike. LDAP.client
is a part of the Protocols.LDAP module.
KEYWORDS
ldap, directory
============================================================================
NAME
create - connect to the Ldap database
SYNTAX
#include <ldap.h>
object Protocols.LDAP.client();
or
object Protocols.LDAP.client(string hostname);
or
object Protocols.LDAP.client(string hostname_and_portnumber);
DESCRIPTION
To access the LDAP directory, you must first connect to it. This is
done with the function Protocols.LDAP.client().
If you give no argument, or give "" as hostname it will connect
to "localhost" (127.0.0.1).
For using nonstandard port, you can use third syntax with
"hostname:portnumber" as string argument.
============================================================================
NAME
error_number - return the last error code
error_string - return the last error description
SYNTAX
#include <ldap.h>
string Protocols.LDAP.client->error_number();
string Protocols.LDAP.client->error_string();
DESCRIPTION
When a Ldap method fails you can get a description of the reason
with this function.
============================================================================
NAME
bind - authenticate to the directory
SYNTAX
#include <ldap.h>
void Protocols.LDAP.client->bind();
or
void Protocols.LDAP.client->bind(string user);
or
void Protocols.LDAP.client->bind(string user, string password);
DESCRIPTION
The Ldap directory server can select access to directory subtree.
Bind current connection to Ldap directory.
If an argument isn't given, bind as guest (user="").
WARNING
Without bind operation you can't access LDAP server under
version 2 LDAP protocol.
SEE ALSO
ldap->create
============================================================================
NAME
search - make an LDAP search query
SYNTAX
#include <ldap.h>
int|object Protocols.LDAP.client->search(string q);
or
int|object Protocols.LDAP.client->search(string q, int attrsonly);
or
int|object Protocols.LDAP.client->search(string q, int attrsonly,
array(string) attrs);
DESCRIPTION
This function search the Ldap directory. The result
of the query is returned as a Protocols.LDAP.client.result object.
Argument 'attrs' limits returned attributes of entries.
If 'attrsonly' is not null, then returned entries contains only
attribute names.
SEE ALSO
Protocols.LDAP.client.result, Protocols.LDAP.client->set_basedn,
Protocols.LDAP.client->set_scope, Protocols.LDAP.client->set_option,
============================================================================
NAME
set_basedn - setup base value
SYNTAX
#include <ldap.h>
string Protocols.LDAP.client->set_basedn(string base);
DESCRIPTION
This function set a base DN for search directory.
Returns previously defined base DN value.
SEE ALSO
Protocols.LDAP.client->search
============================================================================
NAME
set_scope - setup a scope
SYNTAX
#include <ldap.h>
int Protocols.LDAP.client->set_scope(int scope);
DESCRIPTION
This function sets the scope for the search directory.
Returns previously defined scope value.
Argument 'scope':
0 LDAP_SCOPE_BASE
1 LDAP_SCOPE_ONELEVEL
2 LDAP_SCOPE_SUBTREE
SEE ALSO
Protocols.LDAP.client->search
============================================================================
NAME
set_option - set session options
get_option - get session options
SYNTAX
#include <ldap.h>
int Protocols.LDAP.client->set_option(int option_type, mixed value);
int Protocols.LDAP.client->get_option(int option_type);
#define LDAP_OPT_DEREF 1 // - Dereference
#define LDAP_OPT_SIZELIMIT 2 // - Maximum number of entries to return
#define LDAP_OPT_TIMELIMIT 3 // - Timeout for LDAP operations
#define LDAP_OPT_REFERRALS 4 // - Follow referrals (UNIMPLEMENTED)
DESCRIPTION
This function sets/gets the current session options.
On success returns 0.
SEE ALSO
Protocols.LDAP.client->search
============================================================================
NAME
delete - delete entry from the Ldap directory
SYNTAX
#include <ldap.h>
int Protocols.LDAP.client->delete(string cn);
DESCRIPTION
This function deletes an entry from the Ldap directory.
Returns 0 if successfull.
SEE ALSO
Protocols.LDAP.client->add, Protocols.LDAP.client->modify
============================================================================
NAME
modify - modify entry in the Ldap directory
SYNTAX
#include <ldap.h>
int Protocols.LDAP.client->modify(string cn,
mapping(string:array(mix)) attropval);
DESCRIPTION
This function modify an entry in the Ldap directory.
Second argument is the following mapping:
attropval = ([string attributename:({int op, string value1 .. n})]);
First element of array MUST be integer value of operation!
Where op = 0 for "add value", 1 for "replace" and 2 for "delete"
Returns 0 if successfull.
Example: (["l":({1, "Prague"}),
"url":({0, "http://www.unibase.cz", "http://www.xyz.com"}),
"mail":({1})
"fax":({2, "+42 69 6207111"})
])
Attribute "l" is replaced, "url" are added,
"mail" is deleted (values was ommited) and "fax" deleted
one value.
SEE ALSO
Protocols.LDAP.client->add, Protocols.LDAP.client->delete
============================================================================
NAME
add - add entry to the LDAP directory
SYNTAX
#include <ldap.h>
int Protocols.LDAP.client->add(string cn,
mapping(string:array(string)) attrs);
DESCRIPTION
This function adds an entry to the Ldap directory.
Returns 0 if successfull.
SEE ALSO
Protocols.LDAP.client->modify, Protocols.LDAP.client->delete
============================================================================
NAME
server_info - some Ldap directory information (UNIMPLEMENTED!!!)
SYNTAX
#include <ldap.h>
object(ldap_entry) Protocols.LDAP.client->server_info();
DESCRIPTION
This function returns some directory information/statistics.
WARNING
This information depends on LDAP server. At present, works
only with servers based on U-Mich LDAP server implementation.
(i.e. Critical Angle Inc. LDAP Server up to 3.3.3.,
Netscape Directory Server 3.0)
REMARK
Emulation these operation is very simple:
object o, e;
o=Protocols.LDAP.client("servername");
o->bind();
o->set_basedn("cn=monitor");
o->set_scope(0);
e=o->search("objectclass=*");
o->unbind();
e->fetch();
EXAMPLE
#include <ldap.h>
int main()
{
write(sprintf("%O", ldap()->server_info()->fetch()));
return(0);
}
SEE ALSO
Protocols.LDAP.client.result
|