Ldap_Add driving me nuts
| From: | James Taylor | Date: | Wed, 12 Mar 2003 04:58:48 +0000 |
| Subject: | Ldap_Add driving me nuts | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-139221@lists.php.net to get a copy of this message | ||
I'm having trouble with the ldap_add function in my script. There are 4
possible classes in the ldap schema that would be used - organization,
person, qmailUser, inetOrgPerson. The ldap_add script will every time
return
LDAP-Errno: 65
LDAP-Error: Object class violation
UNLESS I include data for person, qmailUser, and inetOrgPerson. There's
nothing in the schema that should be doing this, so I'm not sure why PHP
is complaining about it. Here's some example code real quick:
<?php
$l=ldap_connect();
ldap_set_option($l, LDAP_OPT_PROTOCOL_VERSION, 3);
$user='cn=Manager,dc=mycompany,dc=com';
ldap_bind($l,$user,'mypassword');
$info = array();
$info['objectClass'][0] = 'organization';
$info['objectClass'][1] = 'qmailUser';
$info['o'] = 'Test Company';
$info['mail'] = 'person@test.com';
$info['uid'] = 'TestCompany';
$info['ou'] = 'devel';
$r=ldap_add($l,
"uid={$info['uid']},ou={$info['ou']},dc=mycompany,dc=com", $info);
if($r) {
echo "Success\n";
} else {
echo "Fail\n";
}
?>
There's really no reason why this shouldn't work as far as I can tell.
Here's the objectClasses for the classes that I'm actually using.
objectclass ( 1.3.6.1.4.1.7914.1.2.2.1 NAME 'qmailUser'
DESC 'QMail-LDAP User' SUP top AUXILIARY
MUST ( mail $ uid )
MAY ( mailMessageStore $ homeDirectory $ userPassword $
mailAlternateAddress $ qmailUID $ qmailGID $ mailQuota $
mailHost $ mailForwardingAddress $ deliveryProgramPath $
qmailDotMode $ deliveryMode $ mailReplyText $
accountStatus $ qmailAccountPurge ) )
objectclass ( 2.5.6.4 NAME 'organization' SUP top STRUCTURAL
MUST o
MAY ( userPassword $ searchGuide $ seeAlso $ businessCategory $
x121Address $ registeredAddress $ destinationIndicator $
preferredDeliveryMethod $ telexNumber $ teletexTerminalIdentifier
$
telephoneNumber $ internationaliSDNNumber $
facsimileTelephoneNumber $ street $ postOfficeBox $ postalCode $
postalAddress $ physicalDeliveryOfficeName $ st $ l $ description
) )
objectclass ( 2.5.6.6 NAME 'person' SUP top STRUCTURAL
MUST ( sn $ cn )
MAY ( userPassword $ telephoneNumber $ seeAlso $ description ) )
objectclass ( 2.16.840.1.113730.3.2.2 NAME 'inetOrgPerson'
DESC 'RFC2798: Internet Organizational Person'
SUP organizationalPerson
STRUCTURAL
MAY (
audio $ businessCategory $ carLicense $ departmentNumber $
displayName $ employeeNumber $ employeeType $ givenName $
homePhone $ homePostalAddress $ initials $ jpegPhoto $
labeledURI $ mail $ manager $ mobile $ o $ pager $
photo $ roomNumber $ secretary $ uid $ userCertificate $
x500uniqueIdentifier $ preferredLanguage $
userSMIMECertificate $ userPKCS12 )
)
objectclass ( 2.5.6.0 NAME 'top' ABSTRACT
MUST objectClass )