LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 10-26-2006, 10:14 AM   #1
ANU
Member
 
Registered: Aug 2003
Location: Romania
Distribution: Solaris 10
Posts: 78

Rep: Reputation: 15
perl + ldap + userPassword hash


hello all

i might need some help with the LDAP perl modules/libraries
im trying to get (remotely) the users password hash from an LDAP server where the password is encrypted. I need this to be able to copy the users information and his hash to my local LDAP server.
I did not figured out how i can do this
i was trying to get some information about the users with
Mozilla::LDAP
but i dont see any argument that would give me the users password hash
maybe NET::LDAP can do the trick

the thing is like this locally when i exec the command
ldapsearch -D "cn=directory manager" -w secretpass -b "ou=people,dc=home,dc=com" uid=*

i get the list of users with that field named userPassword
Code:
dn: uid=wagner,ou=People,dc=home,dc=com
loginShell: /bin/ksh
gidNumber: 1001
objectClass: top
objectClass: account
objectClass: person
objectClass: inetOrgPerson
objectClass: organizationalPerson
objectClass: posixAccount
objectClass: shadowaccount
homeDirectory: /home/*****
cn: ****
givenName: ****
uidNumber: *****
gecos: *****
sn: *****
uid: ****
userPassword: {SSHA}oEx4GlxT+q16S/D3TGZAK50mdMhwZlBGtgiTEw==
im interested how i can get this fields userPassword value with some Perl libraries/functions not with ldapsearch

Last edited by ANU; 10-31-2006 at 04:12 AM.
 
Old 10-26-2006, 11:49 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374
Hi,

You can indeed use Net::LDAP.

Basically you need to set up the connections first, something like this:
Code:
# ------------------------------------------------------------------ #
# - connectToLdap - Open a connection to ldap instance
# ------------------------------------------------------------------ #
sub connectToLdap {
  # connect to instance
  $ldapConn = Net::LDAP->new ($confValues{localAdminIP},
                              port=>$confValues{ldapPort});
  # ooops
  die "Can't connect to $instanceName" unless $ldapConn;

  # bind with credentials
  $ldapConn->bind (dn=>$confValues{ldapBindDn},
                   password=>$confValues{ldapMasterPasswd});
}
Then you can do your searches/modifications.
A search example:
Code:
# ------------------------------------------------------------------ #
# - Search - Search connection tree for given attribute
# ------------------------------------------------------------------ #
sub conTreeSearch {
  # search db
  $ctsResult = $ldapConn->search (base   => "$confValues{ldapBase}",
                                  scope  => "sub",
                                  filter => "(attribute=$_)",
                                  attrs  => ["otherattribute"]);
  $ctEntry = $ctsResult->entry(0);
}
And finally you close the connection again:
Code:
 # close session
$ldapConn->unbind;
As you probably noticed $confValues{<sometoken>} is filled with the actual entries .

Hope this helps.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using hash value as key for other hash in Perl scuzzman Programming 6 02-14-2006 06:08 PM
Perl and Hash automatic PB0711 Programming 3 09-23-2005 03:14 AM
Perl: hash tying amnesty_puppy Programming 1 01-18-2005 12:03 AM
LDAP Authentication(UserPassword validation) joeyBig Linux - General 4 09-21-2004 06:50 PM
Hash-sort like in PERL in C++ nyk Programming 4 06-11-2004 09:40 AM


All times are GMT -5. The time now is 06:19 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration