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

Rowland Penny rpenny at samba.org
Wed Jun 28 08:32:48 UTC 2017


On Tue, 27 Jun 2017 18:55:04 +0300
Alexander Bokovoy <ab at samba.org> wrote:

> On ti, 27 kesä 2017, Rowland Penny via samba-technical wrote:
> > On Tue, 27 Jun 2017 17:57:10 +0300
> > Alexander Bokovoy <ab at samba.org> wrote:
> > 
> > > On ti, 27 kesä 2017, Rowland Penny via samba-technical wrote:
> > > > > > 
> > > > > >     "sAMAccountType=%d"... % (dsdb.UF_NORMAL_ACCOUNT,...
> > > > > > 
> > > > > > 'pydoc samba.dsdb' shows this:
> > > > > > 
> > > > > >     UF_NORMAL_ACCOUNT = 512
> > > > > > 
> > > > > > This means that the filter will become:
> > > > > > 
> > > > > > sAMAccountType=512
> > > > > > 
> > > > > > Don't think that is a valid number for sAMAccountType, it
> > > > > > is for userAccountControl though.
> > > > > > 
> > > > > > My way seems to be the accepted filter to just get a user.
> > > > > It is samba.dsdb.ATYPE_NORMAL_ACCOUNT, not UF_NORMAL_ACCOUNT.
> > > > > Please use this one.
> > > > 
> > > > I knew it wasn't correct, but for the ignorant (i.e. me), why
> > > > use 'ATYPE_NORMAL_ACCOUNT' instead of '805306368' ?
> > > There are few reasons:
> > >  - using symbolic constants is more readable. For me, at least,
> > > as I don't remember all constants by heart.
> > 
> > Valid reason, I usually have to look things like this up.
> > 
> > >  - using symbolic constants avoids subtle typo issues. Errors in
> > > typing are not unknown.
> > 
> > Really understand this, I could be the king of typo's, never mind
> > incorrectly spelt words, I can completely miss out entire words ;-)
> > 
> > > 
> > > We have few more places in the Python code that refer to a normal
> > > account type by its numeric value. Using constants helps to reduce
> > > likeability of an error that would be very hard to spot otherwise.
> > 
> > Sorry, but I had to read that last sentence several times before I
> > understood it. I think you meant 'Using constants helps to increase
> > the likelihood of seeing hard to spot errors.'. If this the case,
> > then I totally agree with you ;-)
> :) If you do a typo and use 805306360 instead of 805306368, it will be
> hard to detect as the code would still work. If you'd do a typo in
> dsdb.ATYPE_NORMAL_ACCOUNT it would fail with 'unknown variable' which
> is easy to see because the code execution will break. That was my
> point.
> 

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.

Rowland
 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: samba-tool-Easily-edit-a-users-object-in-AD.patch
Type: text/x-patch
Size: 6436 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20170628/84beba40/samba-tool-Easily-edit-a-users-object-in-AD.bin>


More information about the samba-technical mailing list