userdir-ldap (0.3.15+xxx) XXunstable; urgency=low
+ [ Peter Palfrader ]
* Ship userdir-ldap.schema with the package, add a note that it is
now version-controlled in bzr on top of the file.
* Get rid of debian/conffiles, wich only listed files in /etc anyway.
* ud-roleadd: Do not try to make role accounts of objectClass
inetOrgPerson, that doesn't work.
- -- Peter Palfrader <weasel@debian.org> Tue, 25 Dec 2007 13:08:50 +0100
+ [ Mark Hymers ]
+ * ud-userimport, ud-groupadd, ud-roleadd, ud-useradd, userdir_ldap.py:
+ Update ud-userimport to use the same objectClasses as
+ ud-{user,group,role}add and abstract them out into userdir_ldap.py
+
+ -- Mark Hymers <mhy@debian.org> Wed, 26 Dec 2007 17:56:28 +0000
userdir-ldap (0.3.15) unstable; urgency=low
if Update == 0:
# New account
Details = [("uid",account),
- ("objectClass",
- ("top","inetOrgPerson","debianAccount","shadowAccount","debianDeveloper")),
+ ("objectClass", UserObjectClasses),
("uidNumber",str(uidNumber)),
("gidNumber",str(gidNumber)),
("gecos",FullName+",,,,"),
#Add user group if needed, then the actual user:
if UserGroup == 1:
Dn = "gid=" + account + "," + BaseDn;
- l.add_s(Dn,[("gid",account), ("gidNumber",str(gidNumber)), ("objectClass",("top", "debianGroup"))]);
+ l.add_s(Dn,[("gid",account), ("gidNumber",str(gidNumber)), ("objectClass", GroupObjectClasses)])
l.add_s(Dn,Details);
else:
(Split[4],cn,mn,sn) = ParseGecos(Split[4]);
CheckNumber(Split[2]);
CheckNumber(Split[3]);
- Rec = [(ldap.MOD_REPLACE,"uid",Split[0]),
- (ldap.MOD_REPLACE,"uidNumber",Split[2]),
- (ldap.MOD_REPLACE,"gidNumber",Split[3]),
- (ldap.MOD_REPLACE,"gecos",Split[4]),
- (ldap.MOD_REPLACE,"homeDirectory",Split[5]),
- (ldap.MOD_REPLACE,"loginShell",Split[6]),
- (ldap.MOD_REPLACE,"cn",cn),
- (ldap.MOD_REPLACE,"mn",mn),
- (ldap.MOD_REPLACE,"sn",sn)];
+ Rec = [("uid",Split[0]),
+ ("uidNumber",Split[2]),
+ ("gidNumber",Split[3]),
+ ("gecos",Split[4]),
+ ("homeDirectory",Split[5]),
+ ("loginShell",Split[6]),
+ ("cn",cn),
+ ("sn",sn)];
+
+ # Avoid schema check complaints when mn is empty
+ if (mn):
+ Rec.append(("mn",mn))
Dn = "uid=" + Split[0] + "," + BaseDn;
- print "Importing",Dn,
+ print "Importing", Dn
sys.stdout.flush();
- # Unfortunately add_s does not take the same args as modify :|
+ DoModify = True
+
if (DoAdd == 1):
try:
- l.add_s(Dn,[("uid",Split[0]),
- ("objectClass","top"),
- ("objectClass","account"),
- ("objectClass","posixAccount"),
- ("objectClass","shadowAccount"),
- ("objectClass","debiandeveloper")]);
+ AddRec = Rec
+ Rec.append(("objectClass", UserObjectClasses))
+ l.add_s(Dn,AddRec)
+ DoModify = False
+
except ldap.ALREADY_EXISTS:
print "exists",;
- # Send the modify request
- l.modify(Dn,Rec);
- Outstanding = Outstanding + 1;
- Outstanding = FlushOutstanding(l,Outstanding,1);
- print "done";
+ if (DoModify):
+ # Send the modify request
+ ModRec = [(ldap.MOD_REPLACE, k[0], k[1]) for k in Rec]
+ l.modify(Dn,ModRec);
+ Outstanding = Outstanding + 1;
+ Outstanding = FlushOutstanding(l,Outstanding,1);
+ print "done";
+
FlushOutstanding(l,Outstanding);
# Read the shadow file into the database
Rec = [(ldap.MOD_REPLACE,"shadowLastChange",Split[2]),
(ldap.MOD_REPLACE,"shadowMin",Split[3]),
(ldap.MOD_REPLACE,"shadowMax",Split[4]),
- (ldap.MOD_REPLACE,"shadowWarning",Split[5]),
- (ldap.MOD_REPLACE,"shadowInactive",Split[6]),
- (ldap.MOD_REPLACE,"shadowExpire",Split[7])];
+ (ldap.MOD_REPLACE,"shadowWarning",Split[5])]
+
+ # Avoid schema violations
+ if (Split[6]):
+ Rec.append((ldap.MOD_REPLACE,"shadowInactive",Split[6]))
+
+ if (Split[7]):
+ Rec.append((ldap.MOD_REPLACE,"shadowExpire",Split[7]))
+
if (WritePasses == 1):
Rec.append((ldap.MOD_REPLACE,"userPassword","{crypt}"+Split[1]));
if (DoAdd == 1):
try:
l.add_s(Dn,[("gid",Split[0]),
- ("objectClass","top"),
- ("objectClass","posixGroup")]);
+ ("objectClass", GroupObjectClasses)])
except ldap.ALREADY_EXISTS:
print "exists",;