[Samba] [PATCH] samba-tool: Easily edit a users object in AD
Rowland Penny
rpenny at samba.org
Tue Jun 27 16:02:33 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.
>
That is easier to understand and explains just why using a variable is
a very good idea, thanks for explaining it.
Rowland
More information about the samba
mailing list