For Programmers: Free Programming Magazines  


Home > Archive > PERL Modules > October 2006 > Net::LDAP::Entry help...









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Net::LDAP::Entry help...
onlineviewer

2006-09-25, 9:58 pm

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');

Charles DeRykus

2006-10-02, 6:58 pm

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

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com