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");
36 Line = List.readline();
39 Split = re.split("[:\n]",Line);
43 Set.append(string.strip(Split[1]));
49 # Generate the command..
50 Rec = [(ldap.MOD_REPLACE,arguments[0],Set[0])];
52 Rec.append((ldap.MOD_ADD,arguments[0],x))
54 Dn = "uid=" + User + "," + BaseDn;
65 Set = [string.strip(Split[1])];