4 # Copyright (c) 1999 Jason Gunthorpe <jgg@debian.org>
5 # Copyright (c) 2004 Joey Schulze <joey@debian.org>
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 # This script imports arbitary lists of data. The input is a file with
25 import re, time, ldap, getopt, sys;
26 from userdir_ldap import *;
29 (options, arguments) = getopt.getopt(sys.argv[1:], "u:m:n")
30 for (switch, val) in options:
33 elif (switch == '-m'):
35 elif (switch == '-n'):
37 if len(arguments) == 0:
38 print "Give the key to assignt to then the file to import";
41 # Main program starts here
42 l = passwdAccessLDAP(BaseDn, AdminUser)
44 List = open(arguments[1],"r");
48 Line = List.readline();
51 Split = re.split("[:\n]",Line);
55 Set.append(Split[1].strip());
61 # Generate the command..
62 Rec = [(ldap.MOD_REPLACE,arguments[0],Set[0])];
64 Rec.append((ldap.MOD_ADD,arguments[0],x))
66 Dn = "uid=" + User + "," + BaseDn;
77 Set = [Split[1].strip()];