[PATCH] samba-tool: Easily edit a users object in AD

Rowland Penny rpenny at samba.org
Fri Jun 30 12:43:47 UTC 2017


On Wed, 28 Jun 2017 12:27:53 +0300
Alexander Bokovoy <ab at samba.org> wrote:

> On ke, 28 kesä 2017, Andrew Bartlett via samba-technical wrote:
> > On Wed, 2017-06-28 at 09:32 +0100, Rowland Penny via samba-technical
> > wrote:
> > > 
> > > OK, the attached patch should meet all problems raised against the
> > > first one, except a test.
> > > 
> > > I am struggling with the test. I can see how I could write a test
> > > that would:
> > > 
> > > Create a user to use in the test.
> > > Run 'samba-tool user edit USER'
> > > 
> > > I cannot then see how I can write code to simulate a sysadmin
> > > altering the users object and/or saving and closing the editor.
> > 
> > You replace the EDITOR with a script that modifies the object's
> > LDIF.
> Yes, something like
> EDITOR="sed -i -e 's/attribute: foo/attribute: bar/'"
> 

OK, this doesn't work, but if I create a dummy editor script, it does.

This is what I came up with:

#!/bin/sh
user_ldif="$1"
SED=$(which sed)
$SED -i -e \'s/userAccountControl: 512/userAccountControl: 514/\' $user_ldif

If I create the above script as /tmp/editor.sh, make it executable and
then pass it to 'samba-tool user USER' with '--editor=/tmp/editor.sh'
it works.

Problem is, how do I either get the python test script to create the
bash script and then use it, or how do I create the bash script
somewhere in the source (if so where?) and then get the python test
script to use it ?

Rowland



More information about the samba-technical mailing list