diff options
author | Gerald Carter <jerry@samba.org> | 2003-05-09 21:51:57 +0000 |
---|---|---|
committer | Gerald Carter <jerry@samba.org> | 2003-05-09 21:51:57 +0000 |
commit | c37cc212c8aab591e725e73d4137f1742ac63d21 (patch) | |
tree | fa186e0d6436026c67e2398268c9d581ecfc734a /examples/LDAP/export_smbpasswd.pl | |
parent | 6278185860e0846b3d7dc3914142b0e0e2b1c5cf (diff) | |
download | samba-c37cc212c8aab591e725e73d4137f1742ac63d21.tar.gz samba-c37cc212c8aab591e725e73d4137f1742ac63d21.tar.bz2 samba-c37cc212c8aab591e725e73d4137f1742ac63d21.zip |
syncing import/export smbpasswd file scripts from 2.2
(This used to be commit ee1374cabf38c3d99e66a45316e232d1c2cfbe6a)
Diffstat (limited to 'examples/LDAP/export_smbpasswd.pl')
-rw-r--r-- | examples/LDAP/export_smbpasswd.pl | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/examples/LDAP/export_smbpasswd.pl b/examples/LDAP/export_smbpasswd.pl index 3f67dc6242..e4f120bf02 100644 --- a/examples/LDAP/export_smbpasswd.pl +++ b/examples/LDAP/export_smbpasswd.pl @@ -5,16 +5,16 @@ ## ## writen by jerry@samba.org ## +## ported to Net::LDAP by dkrovich@slackworks.com -use Mozilla::LDAP::Conn; -use Mozilla::LDAP::Entry; +use Net::LDAP; ###################################################### ## Set these values to whatever you need for your site ## -$DN="ou=people,dc=plainjoe,dc=org"; -$ROOTDN="cn=Manager,dc=plainjoe,dc=org"; +$DN="dc=samba,dc=my-domain,dc=com"; +$ROOTDN="cn=Manager,dc=my-domain,dc=com"; $rootpw = "secret"; $LDAPSERVER="localhost"; @@ -22,9 +22,7 @@ $LDAPSERVER="localhost"; ## end local site variables ###################################################### - -$conn = new Mozilla::LDAP::Conn ("$LDAPSERVER", "389", $ROOTDN, $rootpw ); -die "Unable to connect to LDAP server $LDAPSERVER" unless $conn; +$ldap = Net::LDAP->new($LDAPSERVER) or die "Unable to connect to LDAP server $LDAPSERVER"; print "##\n"; print "## Autogenerated smbpasswd file via ldapsearch\n"; @@ -32,32 +30,35 @@ print "## from $LDAPSERVER ($DN)\n"; print "##\n"; ## scheck for the existence of the posixAccount first -$result = $conn->search ("$DN", "sub", "(objectclass=smbPasswordEntry)"); - - +$result = $ldap->search ( base => "$DN", + scope => "sub", + filter => "(objectclass=sambaAccount)" + ); + + + ## loop over the entries we found -while ($result) { - - @uid = $result->getValue("uid"); - @uidNumber = $result->getValue("uidNumber"); - @lm_pw = $result->getValue("lmpassword"); - @nt_pw = $result->getValue("ntpassword"); - @acct = $result->getValue("acctFlags"); - @pwdLastSet = $result->getValue("pwdLastSet"); - +while ( $entry = $result->shift_entry() ) { + + @uid = $entry->get_value("uid"); + @uidNumber = $entry->get_value("uidNumber"); + @lm_pw = $entry->get_value("lmpassword"); + @nt_pw = $entry->get_value("ntpassword"); + @acct = $entry->get_value("acctFlags"); + @pwdLastSet = $entry->get_value("pwdLastSet"); + if (($#uid+1) && ($#uidNumber+1)) { - + $lm_pw[0] = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" if (! ($#lm_pw+1)); $nt_pw[0] = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" if (! ($#nt_pw+1)); $acct[0] = "[DU ]" if (! ($#acct+1)); $pwdLastSet[0] = "FFFFFFFF" if (! ($#pwdLastSet+1)); - + print "$uid[0]:$uidNumber[0]:$lm_pw[0]:$nt_pw[0]:$acct[0]:LCT-$pwdLastSet[0]\n"; } - - $result = $conn->nextEntry(); - + } -$conn->close(); +$ldap->unbind(); exit 0; + |