Are there Python3 libraries for the net commands and etc?
John Mulligan
phlogistonjohn at asynchrono.us
Thu Mar 31 17:56:09 UTC 2022
On Tuesday, March 29, 2022 3:20:53 PM EDT David Mulder via samba-technical
wrote:
> On 3/28/22 1:44 PM, Richard Sharpe via samba-technical wrote:
> > smb_mgmt_net_ads_join/smb_mgmt_net_ads_leave
>
> These already have bindings. See the python module `samba.net_s3`.
>
> > smb_mgmt_net_ads_status
>
> This appears to just do an ldap search for the local host, to see info
> about the join?
> You could write something similar using the samba.samdb python module.
> So,
> ```
> from samba.samdb import SamDB
> from samba.auth import system_session
> samdb = SamDB(url='ldap://some-server', session_info=system_session(),
> credentials=creds, lp=lp)
> samdb.search(...)
> ```
> The net ads status command searches for these attributes:
> "objectClass",
> "SamAccountName",
> "userAccountControl",
> "DnsHostName",
> "ServicePrincipalName",
> "userPrincipalName",
> "unicodePwd",
> "msDS-AdditionalDnsHostName",
> "msDS-SupportedEncryptionTypes",
> "nTSecurityDescriptor",
> "objectSid"
> With the filter: `"(samAccountName=%s$)" % machine_name`
>
> > smb_mgmt_net_conf_list
> > smb_mgmt_net_conf_setparm
>
> We don't have bindings for these right now. It probably wouldn't be
> difficult to add them though.
I'm interested in contributing patches for this. I've already looked at the
code needed to be wrapped (lib/smbconf and source3/lib/smbconf). I've even
started prototyping. I've done C/Python APIs before, but it's been a while
and I'm rusty, so I'll probably start by making a draft merge request for a
subset of these API to get early feedback.
More information about the samba-technical
mailing list