我有一个问题,我已经在我的centos服务器上安装了open ds,我想通过网页将一些数据保存在open ds服务器上,我会使用php / mysql,任何机构对此都有想法
提前致谢
罗山
最佳答案
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
</head>
<body>
<?php
$ldapconfig['host'] = 'PC100';
$ldapconfig['port'] = 1389;
$ldapconfig['basedn'] = 'dc=company,dc=com';
$ds=ldap_connect($ldapconfig['host'], $ldapconfig['port']);
$password=1;
$username="cn=Directory Manager";
if ($bind=ldap_bind($ds, $username, $password)) {
echo("Login correct");
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3); // IMPORTANT
$dn = "cn=Directory Managerk,dc=example,dc=com";
//$ldaprecord['cn'] = "opp";
$ldaprecord['givenName'] = "mkljl";
$ldaprecord['sn'] = "roshan";
$ldaprecord['objectclass'][0] = "inetOrgPerson";
$ldaprecord['objectclass'][1] = "test";
$ldaprecord['mail'] = "[email protected]";
//$encode=utf8_encode("වවවවවවවවවවව");
//die(print_r(utf8_decode($encode)));
$ldaprecord['attr'] ="වවවවවවවවවවව";
// add data to directory
$r = ldap_add($ds, $dn, $ldaprecord);
// $r= ldap_modify($ds, $dn, $ldaprecord);
} else {
echo("Unable to bind to server.</br>");
}
?>
</body>
</html>