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

Rowland Penny rpenny at samba.org
Tue Jun 27 15:21:37 UTC 2017


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 ;-)

Rowland



More information about the samba-technical mailing list