Net::LDAP::Entry help...

Net::LDAP::Entry help...

am 26.09.2006 04:11:05 von lancerset

Hello All,
I am having a problem with getting this to work. In this code section
I'm fetching data from mysql and assigning it to the array @Users
array. $Users[0] contains username and $Users[1] contains the password.
So i'm trying to add this info to my ldap server. The script runs, but
ldap does not contain the new entry. I'm not sure if this is a good way
to go about this. If you need more code section let me know. Any
suggestions ??? Thanks,

use Net::LDAP::Entry;
while ( @Users = $sth->fetchrow_array( ) ) {
$entry = Net::LDAP::Entry->new;
$entry->dn($host);
$entry->add('uid' => '$Users[0]' );
$entry->add('userPassword' => '$Users[1]' );
$entry->add('givenName' => '$Users[0]' );
$entry->add('loginShell' => '/bin/bash' );
$entry->add('gidNumber' => '2222' );
$entry->add('homeDirectory' => '/home/ftpusers/$Users[0]' );
$entry->add('objectClass' => 'top');
$entry->add('objectClass' => 'person');
$entry->add('objectClass' => 'posixAccount');

Re: Net::LDAP::Entry help...

am 03.10.2006 01:22:51 von Charles DeRykus

onlineviewer wrote:
> Hello All,
> I am having a problem with getting this to work. In this code section
> I'm fetching data from mysql and assigning it to the array @Users
> array. $Users[0] contains username and $Users[1] contains the password.
> So i'm trying to add this info to my ldap server. The script runs, but
> ldap does not contain the new entry. I'm not sure if this is a good way
> to go about this. If you need more code section let me know. Any
> suggestions ??? Thanks,
>
> use Net::LDAP::Entry;
> while ( @Users = $sth->fetchrow_array( ) ) {
> $entry = Net::LDAP::Entry->new;
> $entry->dn($host);
> $entry->add('uid' => '$Users[0]' );
> $entry->add('userPassword' => '$Users[1]' );
> $entry->add('givenName' => '$Users[0]' );
> $entry->add('loginShell' => '/bin/bash' );
> $entry->add('gidNumber' => '2222' );
> $entry->add('homeDirectory' => '/home/ftpusers/$Users[0]' );
> $entry->add('objectClass' => 'top');
> $entry->add('objectClass' => 'person');
> $entry->add('objectClass' => 'posixAccount');
>

Take a look at the NOTE below from the Net::LDAP::Entry doc:

...
$entry->add ( 'sn' => 'Barr' );
$entry->add ( 'street' => [ '1 some road','nowhere' ] );

NOTE: these changes are local to the client and will not
appear on the directory server until the "update" method
is called.

--
Charles DeRykus