summaryrefslogtreecommitdiff
path: root/source4/scripting
diff options
context:
space:
mode:
authorLukasz Zalewski <lukas@eecs.qmul.ac.uk>2012-05-09 14:24:01 +0100
committerAndrew Bartlett <abartlet@samba.org>2012-05-10 14:58:46 +1000
commitbe5bf2c991ce5ec2c5b2c19832430e26150d7d84 (patch)
treea89628fef9a3a4a5f079e4c22d88143dd86594b6 /source4/scripting
parentd74c5a3dc4ff81eadf220b4554401e786e93dab5 (diff)
downloadsamba-be5bf2c991ce5ec2c5b2c19832430e26150d7d84.tar.gz
samba-be5bf2c991ce5ec2c5b2c19832430e26150d7d84.tar.bz2
samba-be5bf2c991ce5ec2c5b2c19832430e26150d7d84.zip
When listing group members allow fallback to cn attribute when samAccountName is not available
Diffstat (limited to 'source4/scripting')
-rw-r--r--source4/scripting/python/samba/netcmd/group.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/source4/scripting/python/samba/netcmd/group.py b/source4/scripting/python/samba/netcmd/group.py
index 265170d2d2..0f4a744acc 100644
--- a/source4/scripting/python/samba/netcmd/group.py
+++ b/source4/scripting/python/samba/netcmd/group.py
@@ -346,13 +346,16 @@ samba-tool group listmembers \"Domain Users\" -H ldap://samba.samdom.example.com
search_filter = "(|(primaryGroupID=%s)(memberOf=%s))" % (rid, group_dn)
res = samdb.search(samdb.domain_dn(), scope=ldb.SCOPE_SUBTREE,
expression=(search_filter),
- attrs=["samAccountName"])
+ attrs=["samAccountName", "cn"])
if (len(res) == 0):
return
for msg in res:
- self.outf.write("%s\n" % msg.get("samAccountName", idx=0))
+ member_name = msg.get("samAccountName", idx=0)
+ if member_name is None:
+ member_name = msg.get("cn", idx=0)
+ self.outf.write("%s\n" % member_name)
except Exception, e:
raise CommandError('Failed to list members of "%s" group ' % groupname, e)