This patch cleans up some of our ldap code, for better behaviour:
authorAndrew Bartlett <abartlet@samba.org>
Fri, 4 Jul 2003 13:29:42 +0000 (13:29 +0000)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 4 Jul 2003 13:29:42 +0000 (13:29 +0000)
commit9c595c8c2327b92a86901d84c3f2c284dabd597e
treeffc6638e3c0cad1779e7ec85e3c48b59c40c1437
parent5280c6953195c2664628ecaab59ea82b4863e8f7
This patch cleans up some of our ldap code, for better behaviour:

We now always read the Domain SID out of LDAP.  If the local secrets.tdb
is ever different to LDAP, it is overwritten out of LDAP.   We also
store the 'algorithmic rid base' into LDAP, and assert if it changes.
(This ensures cross-host synchronisation, and allows for possible
integration with idmap).  If we fail to read/add the domain entry, we just
fallback to the old behaviour.

We always use an existing DN when adding IDMAP entries to LDAP, unless
no suitable entry is available.  This means that a user's posixAccount
will have a SID added to it, or a user's sambaSamAccount will have a UID
added.  Where we cannot us an existing DN, we use
'sambaSid=S-x-y-z,....' as the DN.

The code now allows modifications to the ID mapping in many cases.

Likewise, we now check more carefully when adding new user entires to LDAP,
to not duplicate SIDs (for users, at this stage), and to add the sambaSamAccount
onto the idmap entry for that user, if it is already established (ensuring
we do not duplicate sambaSid entries in the directory).

The allocated UID code has been expanded to take into account the space
between '1000 - algorithmic rid base'.  This much better fits into what
an NT4 does - allocating in the bottom part of the RID range.

On the code cleanup side of things, we now share as much code as
possible between idmap_ldap and pdb_ldap.

We also no longer use the race-prone 'enumerate all users' method for
finding the next RID to allocate.  Instead, we just start at the bottom
of the range, and increment again if the user already exists.  The first
time this is run, it may well take a long time, but next time will just
be able to use the next Rid.

Thanks to metze and AB for double-checking parts of this.

Andrew Bartlett
examples/LDAP/samba.schema
source/include/smbldap.h
source/lib/smbldap.c
source/passdb/passdb.c
source/passdb/pdb_ldap.c
source/sam/idmap_ldap.c
source/sam/idmap_util.c
source/smbd/server.c
source/utils/pdbedit.c