3 # This script imports arbitary lists of data. The input is a file with
7 import string, re, time, ldap, getopt, sys;
8 from userdir_ldap import *;
11 (options, arguments) = getopt.getopt(sys.argv[1:], "u:m:n")
12 for (switch, val) in options:
15 elif (switch == '-m'):
17 elif (switch == '-n'):
19 if len(arguments) == 0:
20 print "Give the key to assignt to then the file to import";
23 # Main program starts here
24 print "Accessing LDAP directory as '" + AdminUser + "'";
25 Password = getpass(AdminUser + "'s password: ");
27 # Connect to the ldap server
28 l = ldap.open(LDAPServer);
29 UserDn = "uid=" + AdminUser + "," + BaseDn;
30 l.simple_bind_s(UserDn,Password);
32 List = open(arguments[1],"r");
34 Line = List.readline();
38 Split = re.split("[:\n]",Line);
40 Rec = [(ldap.MOD_REPLACE,arguments[0],string.strip(Split[1]))];
41 Dn = "uid=" + Split[0] + "," + BaseDn;