| 1 |
lars |
1 |
First of all connect as usual. (Some servers require authentication to get the
|
|
|
2 |
RootDSE entry)
|
|
|
3 |
|
|
|
4 |
$config = array( 'host' => 'localhost' );
|
|
|
5 |
$ldap = Net_LDAP2::connect( $config );
|
|
|
6 |
if( Net_LDAP2::isError( $ldap ) ) die( $ldap->getMessage() );
|
|
|
7 |
|
|
|
8 |
Now we can get the entry:
|
|
|
9 |
|
|
|
10 |
$dse = $ldap->rootDSE();
|
|
|
11 |
if( Net_LDAP2::isError( $dse ) die( $dse->getMessage() );
|
|
|
12 |
|
|
|
13 |
You can give an array of attributes to fetch as an parameter ro rootDSE().
|
|
|
14 |
If none are given these ones are fetched:
|
|
|
15 |
|
|
|
16 |
namingContexts
|
|
|
17 |
altServer
|
|
|
18 |
supportedExtension
|
|
|
19 |
supportedControl
|
|
|
20 |
supportedSASLMechanisms
|
|
|
21 |
supportedLDAPVersion
|
|
|
22 |
subschemaSubentry
|
|
|
23 |
|
|
|
24 |
Then you can work with the object:
|
|
|
25 |
|
|
|
26 |
$basedn = $dse->getValue( 'namingContexts' );
|
|
|
27 |
|
|
|
28 |
if( $dse->supportedVersion( 3 ) == 3 ) {
|
|
|
29 |
do_something_only_ldap_v3_can_do();
|
|
|
30 |
}
|
|
|
31 |
|
|
|
32 |
Public functions:
|
|
|
33 |
|
|
|
34 |
getValue( string )
|
|
|
35 |
|
|
|
36 |
get the value of this attribute. same syntax as Net_LDAP2_Entry::get_value()
|
|
|
37 |
|
|
|
38 |
supportedControl( oid )
|
|
|
39 |
supportedExtension( oid )
|
|
|
40 |
|
|
|
41 |
check if the given control/extension is supported by the server
|
|
|
42 |
|
|
|
43 |
supportedSASLMechanism( mechanism )
|
|
|
44 |
|
|
|
45 |
check if the given sasl mechanism is supported by the server
|
|
|
46 |
|
|
|
47 |
supportedVersion( version )
|
|
|
48 |
|
|
|
49 |
check if the given ldap version is supported by the serve
|
|
|
50 |
|
|
|
51 |
These are alias functions of the above, to make the api perl-ldap compatible.
|
|
|
52 |
|
|
|
53 |
get_value()
|
|
|
54 |
supported_control()
|
|
|
55 |
supported_extension()
|
|
|
56 |
supported_sasl_mechanism()
|
|
|
57 |
supported_version()
|