[Samba] scripting user adds/deletes

steve steve at steve-ss.com
Wed Jul 23 16:05:05 MDT 2014


On Wed, 2014-07-23 at 14:38 -0700, David Bear wrote:
> But we do need to script it because our source for users in our system
> comes from another data base. Any new users, or change of status for
> existing users is pulled from a data base. We don't want to have to rekey
> something that should be automated.
> 
> I could use python to call the samba-tool script -- a python script. This
> would require a call to os.popen or some other call that would make a
> shell, call samba-tool with args, and then return.
> 
> I was hoping that I could import some function directly in to my python
> script and call it that way. Is there a python api doc or something that I
> could use as a reference?
> 
Hi
We've no coding skills whatsoever but wrapped around ldbmodify quite
easily with bash. Here is an example of a domain user kitted out for his
choice of either a Linux or Windows workstation under a file server
called altea:
unixHomeDirectory: /home/users/steve2
loginShell: /bin/bash
profilePath: \\altea\profiles\steve2
homeDrive: Z:
homeDirectory: \\altea\users\steve2
gidNumber: 20513
uidNumber: 3000021

Add a 'blank' user using samba-tool user add and modify to taste.
deactivate with samba-tool user password

Hope this inspires,
Steve


> On Wed, Jul 23, 2014 at 12:21 AM, Quentin Gibeaux <qgibeaux at iris-tech.fr>
> wrote:
> 
> > On 23/07/2014 08:17, David Bear wrote:
> >
> >> I'm wanting to build a script that will add and remove or deactivate
> >> users.
> >> My language is python. are there are docs that describe how to use some of
> >> the python modules to do this?
> >>
> >>  No need to build a script :
> >
> > root at server:~# samba-tool user
> > Usage: samba-tool user <subcommand>
> >
> > User management.
> >
> >
> > Options:
> >   -h, --help  show this help message and exit
> >
> >
> > Available subcommands:
> >   add          - Create a new user.
> >   create       - Create a new user.
> >   delete       - Delete a user.
> >   disable      - Disable an user.
> >   enable       - Enable an user.
> >   list         - List all users.
> >   password     - Change password for a user account (the one provided in
> > authentication).
> >   setexpiry    - Set the expiration of a user account.
> >   setpassword  - Set or reset the password of a user account.
> > For more help on a specific subcommand, please type: samba-tool user
> > <subcommand> (-h|--help)
> > --
> > To unsubscribe from this list go to the following URL and read the
> > instructions:  https://lists.samba.org/mailman/options/samba
> >
> 
> 
> 
> -- 
> David Bear
> mobile: (602) 903-6476




More information about the samba mailing list