01.
<?php
02.
$host
=
'10.1.1.52'
;
03.
$post
=
'389'
;
04.
$user
=
'admin99'
;
05.
$pass
=
'1622P9'
;
06.
$ldap_dn
=
"dc=holinefisher,dc=co,dc=th"
;
07.
08.
$con
= ldap_connect(
$host
,
$post
)
or
die
(
" Can't LDAP "
);
09.
10.
ldap_set_option(
$con
, LDAP_OPT_PROTOCOL_VERSION, 3);
11.
12.
ldap_bind(
$con
,
$user
,
$pass
)
or
die
(
" Can't Server "
);
13.
14.
15.
16.
$name
=
'name@linefisher.co.th'
;
17.
18.
try{
19.
$attributes
=
array
(
"InternetAddress"
,
"JobTitle"
,
"JrnFile"
);
20.
21.
$filter
=
"(&(objectCategory=person)(sAMAccountName=$name))"
;
22.
$result
= ldap_search(
$con
,
$ldap_dn
,
$filter
,
$attributes
);
23.
$entries
= ldap_get_entries(
$con
,
$result
);
24.
if
(
$entries
[
"count"
] > 0){
25.
26.
for
(
$x
=0;
$x
<
$entries
[
"count"
];
$x
++) {
27.
echo
"A : "
.
$entries
[
$x
][
"InternetAddress"
][0] .
"<br />"
;
28.
echo
"B : "
.
$entries
[
$x
][
"JobTitle"
][0] .
"<br />"
;
29.
echo
"C : "
.
$entries
[
$x
][
"JrnFile"
][0] .
"<br />"
;
30.
}
31.
}
32.
}
33.
catch(Exception
$e
){
34.
ldap_unbind(
$con
);
35.
return
;
36.
}
37.
?>