projects
/
mirror
/
userdir-ldap.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
changelog
[mirror/userdir-ldap.git]
/
ud-userimport
diff --git
a/ud-userimport
b/ud-userimport
index
4a21daf
..
db81b65
100755
(executable)
--- a/
ud-userimport
+++ b/
ud-userimport
@@
-37,7
+37,7
@@
# ldapimport -s /etc/shadow -g /etc/group
#
# ldapimport -s /etc/shadow -g /etc/group
#
-import
string,
re, time, ldap, getopt, sys;
+import re, time, ldap, getopt, sys;
from userdir_ldap import *;
DoAdd = 0;
from userdir_ldap import *;
DoAdd = 0;
@@
-71,11
+71,6
@@
def ParseGecos(Field):
Gecos[3] + "," + Gecos[4];
return (Field,cn,mn,sn);
Gecos[3] + "," + Gecos[4];
return (Field,cn,mn,sn);
-# Check if a number string is really a number
-def CheckNumber(Num):
- for x in Num:
- string.index(string.digits,x);
-
# Read the passwd file into the database
def DoPasswd(l,Passwd):
# Read the passwd file and import it
# Read the passwd file into the database
def DoPasswd(l,Passwd):
# Read the passwd file and import it
@@
-88,8
+83,10
@@
def DoPasswd(l,Passwd):
Split = re.split("[:\n]",Line);
(Split[4],cn,mn,sn) = ParseGecos(Split[4]);
Split = re.split("[:\n]",Line);
(Split[4],cn,mn,sn) = ParseGecos(Split[4]);
- CheckNumber(Split[2]);
- CheckNumber(Split[3]);
+ # This just tests whether these are integers and throws an
+ # exception if not
+ int(Split[2])
+ int(Split[3])
Rec = [("uid",Split[0]),
("uidNumber",Split[2]),
("gidNumber",Split[3]),
Rec = [("uid",Split[0]),
("uidNumber",Split[2]),
("gidNumber",Split[3]),
@@
-111,8
+108,8
@@
def DoPasswd(l,Passwd):
if (DoAdd == 1):
try:
if (DoAdd == 1):
try:
- AddRec = Rec
- Rec.append(("objectClass", UserObjectClasses))
+ AddRec = Rec
[:]
+
Add
Rec.append(("objectClass", UserObjectClasses))
l.add_s(Dn,AddRec)
DoModify = False
l.add_s(Dn,AddRec)
DoModify = False
@@
-148,7
+145,7
@@
def DoShadow(l,Shadow):
continue;
for x in range(2,8):
continue;
for x in range(2,8):
- CheckNumber(Split[x]);
+ int(Split[x])
Rec = [(ldap.MOD_REPLACE,"shadowLastChange",Split[2]),
(ldap.MOD_REPLACE,"shadowMin",Split[3]),
Rec = [(ldap.MOD_REPLACE,"shadowLastChange",Split[2]),
(ldap.MOD_REPLACE,"shadowMin",Split[3]),
@@
-189,7
+186,7
@@
def DoGroup(l,Group):
# Split up the group information
Split = re.split("[:\n]",Line);
Members = re.split("[, ]*",Split[3]);
# Split up the group information
Split = re.split("[:\n]",Line);
Members = re.split("[, ]*",Split[3]);
- CheckNumber(Split[2]);
+ int(Split[2])
# Iterate over the membership list and add the membership information
# To the directory
# Iterate over the membership list and add the membership information
# To the directory
@@
-252,7
+249,7
@@
for (switch, val) in options:
# Main program starts here
# Connect to the ldap server
# Main program starts here
# Connect to the ldap server
-l = passwdAccessLDAP(
LDAPServer,
BaseDn, AdminUser)
+l = passwdAccessLDAP(BaseDn, AdminUser)
if (Passwd != ""):
DoPasswd(l,Passwd);
if (Passwd != ""):
DoPasswd(l,Passwd);