ขอบคุณครับ..ผมลองทั้ง 2 แบบแล้วแต่มันยังไม่ได้ แต่กรณีที่ 2 error มันเปลี่ยนไปครับ และผลที่ได้เป็นแบบนี้ครับ
1.
โค้ด: เลือกทั้งหมด
<?php
$ds = ldap_connect("172.16.1.10"); // assuming the LDAP server is on this host
if ($ds) {
// prepare data
$info["cn"] = "John Jones";
$info["sn"] = "Jones";
$info["mail"] = "[email protected]";
$info["objectclass"][0] = "top";
$info["objectclass"][1] = "person";
//$info["objectclass"][2] = "organizationalPerson";
//$info["objectclass"][3] = "user";
// add data to directory
$ldapbind = ldap_bind($ds,"[email protected]", "xxxx");
if ($ldapbind) {
echo "LDAP bind successful...";
$ad = ldap_add($ds, "CN=Jones, ou=CRHuser, DC=crhdomain, DC=local", $info);
} else {
echo "LDAP bind failed...";
}
ldap_close($ds);
} else {
echo "Unable to connect to LDAP server";
}
?>
ผลลัพธ์
LDAP bind successful...
Warning: ldap_add() [function.ldap-add]: Add: Invalid DN syntax in C:\AppServ\www\AD2\add2.php on line 16
และวีธีที่ 2 ตัด objectclass ออกไป
โค้ด: เลือกทั้งหมด
<?php
$ds = ldap_connect("172.16.1.10"); // assuming the LDAP server is on this host
if ($ds) {
// prepare data
$info["cn"] = "John Jones";
$info["sn"] = "Jones";
$info["mail"] = "[email protected]";
// add data to directory
$ldapbind = ldap_bind($ds,"[email protected]", "xxxx");
if ($ldapbind) {
echo "LDAP bind successful...";
$ad = ldap_add($ds, "CN=Jones, ou=CRHuser, DC=crhdomain, DC=local", $info);
} else {
echo "LDAP bind failed...";
}
ldap_close($ds);
} else {
echo "Unable to connect to LDAP server";
}
?>
ผลลัพธ์
LDAP bind successful...
Warning: ldap_add() [function.ldap-add]: Add: Object class violation in C:\AppServ\www\AD2\add2.php on line 16
ขอบคุณครับ..ผมลองทั้ง 2 แบบแล้วแต่มันยังไม่ได้ แต่กรณีที่ 2 error มันเปลี่ยนไปครับ และผลที่ได้เป็นแบบนี้ครับ
1.
[code]<?php
$ds = ldap_connect("172.16.1.10"); // assuming the LDAP server is on this host
if ($ds) {
// prepare data
$info["cn"] = "John Jones";
$info["sn"] = "Jones";
$info["mail"] = "
[email protected]";
$info["objectclass"][0] = "top";
$info["objectclass"][1] = "person";
//$info["objectclass"][2] = "organizationalPerson";
//$info["objectclass"][3] = "user";
// add data to directory
$ldapbind = ldap_bind($ds,"
[email protected]", "xxxx");
if ($ldapbind) {
echo "LDAP bind successful...";
$ad = ldap_add($ds, "CN=Jones, ou=CRHuser, DC=crhdomain, DC=local", $info);
} else {
echo "LDAP bind failed...";
}
ldap_close($ds);
} else {
echo "Unable to connect to LDAP server";
}
?> [/code]
ผลลัพธ์
[quote]LDAP bind successful...
Warning: ldap_add() [function.ldap-add]: Add: Invalid DN syntax in C:\AppServ\www\AD2\add2.php on line 16[/quote]
และวีธีที่ 2 ตัด objectclass ออกไป
[code]<?php
$ds = ldap_connect("172.16.1.10"); // assuming the LDAP server is on this host
if ($ds) {
// prepare data
$info["cn"] = "John Jones";
$info["sn"] = "Jones";
$info["mail"] = "
[email protected]";
// add data to directory
$ldapbind = ldap_bind($ds,"
[email protected]", "xxxx");
if ($ldapbind) {
echo "LDAP bind successful...";
$ad = ldap_add($ds, "CN=Jones, ou=CRHuser, DC=crhdomain, DC=local", $info);
} else {
echo "LDAP bind failed...";
}
ldap_close($ds);
} else {
echo "Unable to connect to LDAP server";
}
?> [/code]
ผลลัพธ์
[quote]LDAP bind successful...
Warning: ldap_add() [function.ldap-add]: Add: Object class violation in C:\AppServ\www\AD2\add2.php on line 16[/quote]