From: joey <> Date: Sun, 21 Nov 2004 10:35:00 +0000 (+0000) Subject: Use the common routine from userdir_ldap.py which asks for the X-Git-Tag: debian_userdir-ldap_0-3-8~31 X-Git-Url: https://git.adam-barratt.org.uk/?p=mirror%2Fuserdir-ldap.git;a=commitdiff_plain;h=9e1e7b0639b1265bf39acd330122f40123451c56 Use the common routine from userdir_ldap.py which asks for the AdminUser password and checks if access if granted to the LDAP server. --- diff --git a/ud-gpgimport b/ud-gpgimport index 1229e57..8c7ad73 100755 --- a/ud-gpgimport +++ b/ud-gpgimport @@ -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 diff --git a/ud-groupadd b/ud-groupadd index 6139556..13f1b8a 100755 --- a/ud-groupadd +++ b/ud-groupadd @@ -1,8 +1,9 @@ #!/usr/bin/env python # -*- mode: python -*- -# Copyright (c) 2000 Jason Gunthorpe +# Copyright (c) 2000 Jason Gunthorpe # Copyright (c) 2001-2003 James Troup +# Copyright (c) 2004 Joey Schulze # # 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? "); diff --git a/ud-killcrypt b/ud-killcrypt index e92aa55..55f198c 100644 --- a/ud-killcrypt +++ b/ud-killcrypt @@ -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"]); diff --git a/ud-userimport b/ud-userimport index cbb6bac..3359782 100755 --- a/ud-userimport +++ b/ud-userimport @@ -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);