Merge usergroups patch in
[mirror/userdir-ldap.git] / userdir_ldap.py
index cfd2c45..c2b864d 100644 (file)
@@ -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