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

Alexander Bokovoy ab at samba.org
Tue Jun 27 14:57:10 UTC 2017


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.
 - using symbolic constants avoids subtle typo issues. Errors in typing
   are not unknown.

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.


-- 
/ Alexander Bokovoy



More information about the samba-technical mailing list