Use the common routine from userdir_ldap.py which asks for the
authorjoey <>
Sun, 21 Nov 2004 10:35:00 +0000 (10:35 +0000)
committerjoey <>
Sun, 21 Nov 2004 10:35:00 +0000 (10:35 +0000)
AdminUser  password and checks if access if granted to the LDAP
server.

ud-gpgimport
ud-groupadd
ud-killcrypt
ud-userimport

index 1229e57..8c7ad73 100755 (executable)
@@ -51,13 +51,10 @@ if len(arguments) == 0:
 # Main program starts here
 
 # Connect to the ldap server
-l = ldap.open(LDAPServer);
 if NoAct == 0:
-   print "Accessing LDAP directory as '" + AdminUser + "'";
-   Password = getpass(AdminUser + "'s password: ");
-   UserDn = "uid=" + AdminUser + "," + BaseDn;
-   l.simple_bind_s(UserDn,Password);
+   l = passwdAccessLDAP(LDAPServer, BaseDn, AdminUser)
 else:
+   l = ldap.open(LDAPServer);
    l.simple_bind_s("","");
 
 # Download the existing key list and put it into a map
index 6139556..13f1b8a 100755 (executable)
@@ -1,8 +1,9 @@
 #!/usr/bin/env python
 # -*- mode: python -*-
 
-#   Copyright (c) 2000  Jason Gunthorpe <jgg@debian.org>
+#   Copyright (c) 2000       Jason Gunthorpe <jgg@debian.org>
 #   Copyright (c) 2001-2003  James Troup <troup@debian.org>
+#   Copyright (c) 2004       Joey Schulze <joey@debian.org>
 #
 #   This program is free software; you can redistribute it and/or modify
 #   it under the terms of the GNU General Public License as published by
@@ -52,13 +53,7 @@ for (switch, val) in options:
    if (switch == '-u'):
       AdminUser = val;
 
-print "Accessing LDAP directory as '" + AdminUser + "'";
-Password = getpass(AdminUser + "'s password: ");
-
-# Connect to the ldap server
-l = ldap.open(LDAPServer);
-UserDn = "uid=" + AdminUser + "," + BaseDn;
-l.simple_bind_s(UserDn,Password);
+l = passwdAccessLDAP(LDAPServer, BaseDn, AdminUser)
 
 while 1:
    Group = raw_input("Group name? ");
index e92aa55..55f198c 100644 (file)
@@ -15,11 +15,7 @@ for (switch, val) in options:
        Anon = 1;
                              
 # Connect to the ldap server
-l = ldap.open(LDAPServer);
-print "Accessing LDAP directory as '" + User + "'";
-Password = getpass(User + "'s password: ");
-UserDn = "uid=" + User + "," + BaseDn;
-l.simple_bind_s(UserDn,Password);
+l = passwdAccessLDAP(LDAPServer, BaseDn, User)
 
 Attrs = l.search_s(BaseDn,ldap.SCOPE_ONELEVEL,"userpassword=*",\
          ["uid","cn","mn","sn","userpassword"]);
index cbb6bac..3359782 100755 (executable)
@@ -220,13 +220,9 @@ for (switch, val) in options:
       AdminUser = val
 
 # Main program starts here
-print "Accessing LDAP directory as '" + AdminUser + "'";
-Password = getpass(AdminUser + "'s password: ");
 
 # Connect to the ldap server
-l = ldap.open(LDAPServer);
-UserDn = "uid=" + AdminUser + "," + BaseDn;
-l.simple_bind_s(UserDn,Password);
+l = passwdAccessLDAP(LDAPServer, BaseDn, User)
 
 if (Passwd != ""):
    DoPasswd(l,Passwd);