diff options
author | Gerald Carter <jerry@samba.org> | 2003-01-19 03:51:32 +0000 |
---|---|---|
committer | Gerald Carter <jerry@samba.org> | 2003-01-19 03:51:32 +0000 |
commit | ea5ffa0371712f822093240a42a9e93c9ff7a28d (patch) | |
tree | 533eb1e2e01d64b0fce10b183b6d4f5b213480eb /examples/LDAP/import_smbpasswd.pl | |
parent | e2f25587530e8c8345c7d24cd6ed7a26c757cabf (diff) | |
download | samba-ea5ffa0371712f822093240a42a9e93c9ff7a28d.tar.gz samba-ea5ffa0371712f822093240a42a9e93c9ff7a28d.tar.bz2 samba-ea5ffa0371712f822093240a42a9e93c9ff7a28d.zip |
only supporting the Net::LDAP module now
(This used to be commit 3e9c970597b190335529e8854f3d2af2c7d8d80e)
Diffstat (limited to 'examples/LDAP/import_smbpasswd.pl')
-rw-r--r-- | examples/LDAP/import_smbpasswd.pl | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/examples/LDAP/import_smbpasswd.pl b/examples/LDAP/import_smbpasswd.pl deleted file mode 100644 index 14aeff967f..0000000000 --- a/examples/LDAP/import_smbpasswd.pl +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/perl -## -## Example script of how you could import and smbpasswd file into an LDAP -## directory using the Mozilla PerLDAP module. -## -## writen by jerry@samba.org -## - -use Mozilla::LDAP::Conn; -use Mozilla::LDAP::Entry; - -################################################# -## set these to a value appropriate for your site -## - -$DN="ou=people,dc=plainjoe,dc=org"; -$ROOTDN="cn=Manager,dc=plainjoe,dc=org"; -$rootpw = "secret"; -$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; - - -while ( $string = <STDIN> ) { - chop ($string); - - ## get the account information - @smbentry = split (/:/, $string); - - ## check for the existence of the posixAccount first - - ## FIXME!! Should do a getownam() and let the NSS modules lookup the account - ## This way you can have a UNIX account in /etc/passwd and the smbpasswd i - ## entry in LDAP. - $result = $conn->search ("$DN", "sub", "(&(uid=$smbentry[0])(objectclass=posixAccount))"); - if ( ! $result ) { - print STDERR "uid=$smbentry[0] does not have a posixAccount entry in the directory!\n"; - next; - } - - print "Updating [" . $result->getDN() . "]\n"; - - ## Do we need to add the 'objectclass: smbPasswordEntry' attribute? - if (! $result->hasValue("objectclass", "smbPasswordEntry")) { - $result->addValue("objectclass", "smbPasswordEntry"); - } - - ## Set other attribute values - $result->setValues ("lmPassword", $smbentry[2]); - $result->setValues ("ntPassword", $smbentry[3]); - $result->setValues ("acctFlags", $smbentry[4]); - $result->setValues ("pwdLastSet", substr($smbentry[5],4)); - - if (! $conn->update($result)) { - print "Error updating!\n"; - } -} - -$conn->close(); -exit 0; |