X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=userdir_ldap.py;h=c2b864d949f3a31e13a685e5451d567bc325f505;hb=94daca1054ff149228a914e095739433deb6e175;hp=cfd2c457c2969cacc968f65bed30173da5f9ffb2;hpb=2ebda936c01060d2dbd3b87292f19b6eec08e805;p=mirror%2Fuserdir-ldap.git diff --git a/userdir_ldap.py b/userdir_ldap.py index cfd2c45..c2b864d 100644 --- a/userdir_ldap.py +++ b/userdir_ldap.py @@ -411,9 +411,18 @@ def GetUID(l,Name,UnknownMap = {}): return (None,None); -def Group2GID(name): - """Returns the numerical id of a common group""" +def Group2GID(l, name): + """ + Returns the numerical id of a common group + on error returns -1 + """ for g in DebianGroups.keys(): if name == g: return DebianGroups[g] - return name + + filter = "(gid=%s)" % name + res = l.search_s(BaseDn,ldap.SCOPE_ONELEVEL,filter,["gidNumber"]); + if res: + return int(GetAttr(res[0], "gidNumber")) + + return -1