简体   繁体   English

如何使用PHP设置多个LDAP对象类?

[英]How to set multiple LDAP object classes with PHP?

I'm trying to receive user data from an Shibboleth/SAML IdP and pass it into an LDAP: 我正在尝试从Shibboleth / SAML IdP接收用户数据并将其传递到LDAP:

// Get data from IdP
$attributes = getUserFromIdP();

// Connect + bind (simplified)
$ldapconn = ldap_connect();
ldap_bind();

// Prepare data
$info['uid']                    = $attributes['uid'][0];
$info['givenName']              = $attributes['givenName'][0];
$info['sn']                     = $attributes['sn'][0];
$info['cn']                     = $attributes['cn'][0];
$info['mail']                   = $attributes['mail'][0];
$info['objectclass'][]          = 'inetOrgPerson';
$info['objectclass'][]          = 'eduPerson'; // problem here!

$dn = "cn=".$info['cn'].",dc=sub,dc=domain,dc=tld";
$r = ldap_add($ldapconn, $dn, $info);

It works fine if I only add inetOrgPerson as objectclass . 如果我仅将inetOrgPerson添加为objectclass它将很好地工作。 But when I try to exclusively set eduPerson or both at the same time, I get an Invalid syntax error (error code 21). 但是,当我尝试同时独占设置eduPerson或同时设置两者时,会收到Invalid syntax错误(错误代码21)。

It doesn't seem to be missing required attributes (that would throw a Object class violation error). 它似乎没有缺少必需的属性(这将引发Object class violation错误)。 So what is the problem here and how can I solve it? 那么这里的问题是什么,我该如何解决呢?

I found the answer: I need to import the eduPerson schema first. 我找到了答案:我需要先导入eduPerson模式。 (A more specific error message would've helped...) (更具体的错误消息会有所帮助...)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM