libwbclient python bindings

Andrew Walker awalker at ixsystems.com
Tue Sep 6 02:29:43 UTC 2022


Hey all,

I made a draft of python bindings for libwbclient.

https://gitlab.com/samba-team/samba/-/merge_requests/2707

They mostly cover areas that I would commonly shell out to `wbinfo` for
(like pinging DC, checking trust creds, seeing which DC winbindd is
currently connected to, and converting SIDs to Unix IDs and vice-versa),
but I would like to make sure that any other common `wbinfo` usage would
also be covered.

Sample:
```
>>> import wbclient
>>> ctx = wbclient.Ctx()
>>> ctx.
ctx.all_domains(       ctx.domain(            ctx.netbios_name
ctx.sids_to_unix_ids(  ctx.version
ctx.dns_domain         ctx.netbios_domain     ctx.separator
 ctx.unix_ids_to_sids(

>>> my_dom = ctx.domain()
>>> my_dom.ping_dc()
'DC01.BILLY.GOAT'
>>> repr(my_dom)
'wbclient.Domain(netbios_domain=BILLY, dns_domain=BILLY.GOAT,
sid=S-1-5-21-1002530428-2020721000-3540273080)'

>>> my_dom.users()
['BILLY\\administrator', 'BILLY\\guest', 'BILLY\\krbtgt', 'BILLY\\joiner',
'BILLY\\user1']

>>> my_dom.groups()
['BILLY\\domain computers', 'BILLY\\domain controllers', 'BILLY\\schema
admins', 'BILLY\\enterprise admins', 'BILLY\\cert publishers',
'BILLY\\domain admins', 'BILLY\\domain users', 'BILLY\\domain guests',
'BILLY\\group policy creator owners', 'BILLY\\ras and ias servers',
'BILLY\\allowed rodc password replication group', 'BILLY\\denied rodc
password replication group', 'BILLY\\read-only domain controllers',
'BILLY\\enterprise read-only domain controllers', 'BILLY\\cloneable domain
controllers', 'BILLY\\protected users', 'BILLY\\key admins',
'BILLY\\enterprise key admins', 'BILLY\\dnsadmins', 'BILLY\\dnsupdateproxy']

>>> my_dom.domain_info()
{'netbios_domain': 'BILLY', 'dns_name': 'BILLY.GOAT', 'sid':
'S-1-5-21-1002530428-2020721000-3540273080', 'domain_flags': {'raw': 7,
'parsed': ['ACTIVE_DIRECTORY', 'NATIVE', 'PRIMARY']}, 'online': True}

>>> ctx.sids_to_unix_ids(['S-1-5-32-544', 'S-1-5-32-545'])
{'mapped': [{'id_type': 'GID', 'id': 90000001}, {'id_type': 'GID', 'id':
90000002}], 'unmapped': []}
```

Just writing this email I realized I probably want to include the SID in
the mapping results.

Is there any other functionality that is desirable?

Andrew


More information about the samba-technical mailing list