ldap_add(): Add: Object class violation error(ldap_add():添加:对象类违规错误)
问题描述
当我尝试通过 PHP 向 OpenDS 添加属性时,出现以下错误:
When I try to add attribute to the OpenDS via PHP I get the following error:
ldap_add(): 添加:对象类违规
ldap_add(): Add: Object class violation
请帮忙.
这是我的代码
<?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=roshan1,dc=example,dc=com";
//$newuser["objectclass"] = "inetOrgPerson";
//$newuser["cn"] = "new1";
//$newuser["sn"] = "user";
$ldaprecord['cn'] = "roshan1";
$ldaprecord['givenName'] = "mkljl";
$ldaprecord['sn'] = "roshan";
$ldaprecord['objectclass'] = "inetOrgPerson";
$ldaprecord['mail'] = "lkl@fh.com";
$ldaprecord['mmmm'] = "77878";
// add data to directory
$r = ldap_add($ds, $dn, $ldaprecord);
} else {
echo("Unable to bind to server.</br>");
}
?>
如果我从代码中删除 $ldaprecord['mmmm'] = "77878";
它可以正常工作.如何添加这样的新属性?
If I remove $ldaprecord['mmmm'] = "77878";
from the code it works fine. How can I add a new attribute like this?
推荐答案
嗯,看起来你只是想将 objectclass
设置为 inetOrgPerson
,但你必须还设置 inetorgPerson
从中扩展的其他上层类-可能是 top
和 person
...
Hmm, it looks like You are trying only to set objectclass
to inetOrgPerson
, but You have to set also other upper classes from which inetorgPerson
is extending - that would be top
and person
maybe...
所以:
$ldaprecord['cn'] = "roshan1";
$ldaprecord['givenName'] = "mkljl";
$ldaprecord['sn'] = "roshan";
$ldaprecord['objectclass'][0] = "top";
$ldaprecord['objectclass'][1] = "person";
$ldaprecord['objectclass'][2] = "inetOrgPerson";
$ldaprecord['mail'] = "lkl@fh.com";
$ldaprecord['mmmm'] = "77878";
这篇关于ldap_add():添加:对象类违规错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:ldap_add():添加:对象类违规错误
基础教程推荐
- 通过 PHP SoapClient 请求发送原始 XML 2021-01-01
- 在多维数组中查找最大值 2021-01-01
- 在 PHP 中强制下载文件 - 在 Joomla 框架内 2022-01-01
- Libpuzzle 索引数百万张图片? 2022-01-01
- 超薄框架REST服务两次获得输出 2022-01-01
- mysqli_insert_id 是否有可能在高流量应用程序中返回 2021-01-01
- 在 Woocommerce 中根据运输方式和付款方式添加费用 2021-01-01
- 如何在 PHP 中的请求之间持久化对象 2022-01-01
- XAMPP 服务器不加载 CSS 文件 2022-01-01
- WooCommerce 中选定产品类别的自定义产品价格后缀 2021-01-01