[Samba] python module

Rowland Penny rpenny at samba.org
Fri Apr 7 19:51:10 UTC 2023



On 07/04/2023 20:20, David Bear via samba wrote:
> I am looking for the python-samba module. I would like to
> add/disable/modify AD accounts using python running on a linux machine.
> ChatGPT suggested the python-samba module.  Sample code as follows:
> 
> from samba.credentials import Credentials
> from samba.netcmd.user import create as create_user
> from samba.netcmd.user import setpassword as set_user_password
> 
> ...
> I am running Debuan bullseye and I can import the samba module. But there
> is no samba.netcmd.user name available. So chatgpt suggested I need a newer
> version of python-samba.
> 
> I attempted to pip install it -- and it is not available on pypi.
> 
> After googling for about 15 minutes I gave up trying to find the
> python-samba module and thought I would ask -- is this something I need to
> get from git ?
> 

As far as I am aware, there isn't one. There is however, a samba C 
module that python can use and the samba in 'samba.netcmd.user' is a 
directory.

A long time ago, I had the same problem and couldn't understand why you 
would name a C module 'samba'.

Can I ask why you are trying to use Python to do something that sounds 
like something that samba-tool can already do ?

For most of this you could just write a wrapper around samba-tool, or 
use LAM or something similar.

 From my understanding, ChatGPT can only work with what is out there on 
the internet and most of what is out there about Samba is full of errors 
and omissions.

Rowland



More information about the samba mailing list