[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: Net::LDAP problem



Ok, here goes some code, I am only including the ldap related lines:

#get a uid and gid that isnt used
$ldap=Net::LDAP->new($server) or die "$@";
$ldap->bind(dn => $rootdn, password => $dnpassword) or die "bind";

$result=$ldap->search (
	base	=> "dc=life,dc=uiuc,dc=edu",
	scope	=> "sub",
	filter	=> "uid=*",
	attrs	=> "*"
	);
ldap code after this to find an unused uid# and gid# from above search this 
works

...other stuff not using ldap, crypting password, figuring days since epoch, 
etc

$dn="uid=$uid,$dnsuffix";
$homedirectory="$homeprefix$uid";
print "$dn\n";

$res=$ldap->add(
  dn => $dn,
  attr => [
	'uid' => $uid,
	'cn' => $geckos,
	'objectClass' => ['account','posixAccount','top','shadowAccount'],
	'shadowMax' => $shadowMax,
	'shadowWarning' => $shadowWarning,
	'loginShell' => $shell,
	'uidNumber' => $id,
	'gidNumber' => $id,
	'homeDirectory' => $homedirectory,
	'geckos' => $geckos,
	'userPassword' => $password,
	'shadowLastChange' => $days
	]
	);

die "unable to add, errorcode #".$res->code() if $res->code();

It will print the dn as it should, then afterward, the script hangs on trying 
to do the add and will not do anything, so it cannot even get to my error 
checking line.  If need be, I can attach a full copy of my code if it would 
be helpful for someone to see it.

Dan


On Tuesday 25 March 2003 11:02 am, Alan Sparks wrote:
> Daniel Davidson said:
> > I am writing a perl script to add a user to our ldap server, and I am
> > having a  bit of a problem.  When I go to actually do the adding of all
> > the account  information, the will keep trying to do the add without
> > giving an error  message.
> >
> > Anyone have an idea about what would cause this, or should I look toward
> > a  different lDAP package such as Mozilla::LDAP?
>
> You've given no information for anyone to venture a guess.  Net::LDAP
> (which I use) does not output error messages itself, you need to look at
> the      Net::LDAP::Message mesg() method to get the error message.
>
> Net::LDAP isn't the most efficient module, but functionally it works fine
> for me.
> -Alan
>
> ===========
> Alan Sparks, UNIX/Linux Systems Administrator    <asparks@doublesparks.net>