From: Chad C. <ccu...@ma...> - 2002-10-22 14:31:41
|
Hi, I'm writing a little script to keep a ldap database in sync with a password file. I'm getting weird errors trying to add new entries and I'm not sure what's going on. When I add the same data to the database in an ldif form, it works fine. using perl-ldap gives me errors about invalid syntax or an object class violation. I'm using the following code which is pretty much right from the examples, any ideas? I am completely stumped. # # if the shadow entries are commented out, I get # Return code: 65 Error: LDAP_OBJECT_CLASS_VIOLATION # # if not, I get # Return code: 21 Error: LDAP_INVALID_SYNTAX sub ldap_add_user{ my ($ldap,$uid,$password) = @_; my $attrs = [ objectClass => ["person", "organizationalPerson", "inetOrgPerson", "account", "posixAccount", "top", "shadowAccount"], cn => $user{$uid}{gecos}, gecos => $user{$uid}{gecos}, uid => $uid, homeDirectory => "/home/$uid", loginShell => $user{$uid}{loginshell}, shadowExpire => $user{$uid}{shadowexpire}, shadowInactive=> $user{$uid}{shadowinactive}, shadowMax => $user{$uid}{shadowmax}, shadowWarning => $user{$uid}{shadowwarning}, shadowLastChange => $user{$uid}{shadowlastchange}, userPassword => "$password", uidNumber => $user{$uid}{uidnumber}, gidNumber => $user{$uid}{gidnumber} ]; my $result = ldap_add($ldap,"uid=$uid,$LDAP_BASE", $attrs); return $result; } sub ldap_add{ my ($ldap,$dn,$attrs) = @_; my $result = $ldap->add($dn, attrs => [ @$attrs ] ); return $result; } -- Chad Cunningham ccu...@ma... "Well, once again my friend, we find that science is a two-headed beast. One head is nice, it gives us aspirin and other modern conveniences,...but the other head of science is bad! Oh beware the other head of science, Arthur, it bites!" |