[PATCH] samdb.py: add_remove_group_members

Rowland Penny repenny241155 at gmail.com
Tue Jan 3 14:21:45 UTC 2017


Hi, I was trying to add a user to a group with samba-tool:

samba-tool group addmembers unixgroup rowland
ldb_wrap open of secrets.ldb
ERROR(exception): Failed to add members "rowland" to group "unixgroup" - Unable to find "rowland". Operation cancelled.
  File "/usr/local/samba/lib/python2.7/site-packages/samba/netcmd/group.py", line 227, in run
    add_members_operation=True)
  File "/usr/local/samba/lib/python2.7/site-packages/samba/samdb.py", line 274, in add_remove_group_members
    raise Exception('Unable to find "%s". Operation cancelled.' % member)
root at member1:~# samba-tool dbcheck
Checking 328 objects
Checked 328 objects (0 errors)

I traced it down to this line:

expression="(|(sAMAccountName=%s)(CN=%s))" % (

Where it searched for sAMAccountName or CN, I have:

dn: CN=rowland,OU=SUDOers,DC=samdom,DC=example,DC=com
CN: rowland

and

dn: CN=Rowland Penny,CN=Users,DC=samdom,DC=example,DC=com
CN: Rowland Penny
sAMAccountName: rowland

The search filter finds both and so fails, the attached patch fixes
this.

Rowland
-------------- next part --------------
A non-text attachment was scrubbed...
Name: add_remove_group_members-search-filter-can-find-mult.patch
Type: text/x-patch
Size: 1287 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20170103/e99bc2b2/add_remove_group_members-search-filter-can-find-mult.bin>


More information about the samba-technical mailing list