[Samba] Winbind and caching - idmap, DC

Ralph Boehme slow at samba.org
Fri Oct 18 19:30:34 UTC 2019


On 10/18/19 8:45 PM, Alexey A Nikitin via samba wrote:
> On Friday, 18 October 2019 10:52:40 PDT Rowland penny via samba wrote:
>> On 18/10/2019 18:26, Alexey A Nikitin via samba wrote:
>>> Hi everyone,
>>>
>>> I have few questions about Winbind on AD DS domain member I'm having difficulty finding answers to in the docs on my own:
>>> * does Winbind remember the last DC it was connected to on shutdown, will it attempt to connect to the same DC on restart or will it go through DC location process again?
>> I don't think it does cache the last DC and as it might not always use 
>> the same DC in the same session, it doesn't really matter
> 
> Under some corner cases which we're hitting (concerning replication delay, I believe) it does.

yes, we've seen that too iirc.

>>> * If yes, will that information be wiped out when one runs 'net cache flush'?
>>> * If yes, is 'net cache flush' necessary when changing idmap configuration? It seems even after winbind restart querying user info still returns old UID, before the idmap config change :-/
>>
>> What do you mean 'changing idmap configuration' ?
>>
>> Why are doing this and more importantly, how are you doing this ?
>>
> 
> Meaning I'd gladly use something like autorid, but apparently it doesn't allocate the range for a given domain until someone from that domain actually authenticates on the machine.

you can precreate ranges, cf net idmap get|set

> As I need to make certain configuration for the user before they log in for the first time, this doesn't work for me. So I use rid backend, but my understanding is that backend needs ranges configured for specific domains, and I don't know ahead of time what domain user belongs to, I only have user's SID.

wbinfo -s SID gives you DOMAIN\USERNAME.

 So the current approach is I use default idmap backend (tdb) after
initial domain join to query user info and get their domain, then I stop
winbind, change backends to autorid for * and rid for user's domain,

oh, that's a hack! :)


> something like
> 
>         idmap config * : backend = autorid
>         idmap config * : range = 100010000-2100010000
>         idmap config * : rangesize = 100000000
>         idmap config <DOMAIN> : backend = rid
>         idmap config <DOMAIN> : range = 10000 - 100010000
> 
> With this approach it appears I have to flush Winbind cache before I can query user info again and get the UID based on the new idmap configuration instead of the old default tdb idmap.

correct.

> Once I get the new UID I can make the necessary configurations and finish the script.
> 
>>> * If yes, can the cache be wiped out selectively, only the idmap cache without the last DC cache (assuming the answer to first question is yes)?
>>> * If no, can 'net cache flush' be done while Winbind is running, will it achieve the desired effect with regards to SID-UID id mapping change without losing connection to a particular DC?
>>
>> It shouldn't matter which DC you connect to, for a given smb.conf, you 
>> should always get the same UID for a given user.
>>
> 
> Sure, but I have to change the smb.conf as an ugly workaround for a limitation outside of my control (I have only user's SID, I don't have their domain nor do I even know how many domains are there in the forest), so UID is expected to change. DC change, on the other hand, is undesired, because this config change and Winbind restart is scripted and happens within seconds after initial domain join, and it is my understanding that if change notification is disabled within AD DS then the new machine account simply doesn't get enough time to replicate to the rest of the DCs in the domain, which is why I'm seeing something like this in the logs after 'net cache flush' and Winbind restart:
> 
> [<TIMESTAMP>,  1] ../source3/winbindd/winbindd_cm.c:1300(cm_prepare_connection)
>   Failed to prepare SMB connection to <DC>: NT_STATUS_LOGON_FAILURE
> [<TIMESTAMP>,  1] ../source3/winbindd/winbindd_cm.c:1160(cm_prepare_connection)
>   authenticated session setup to <DC> using <DOMAIN>\<HOSTNAME>$ failed with NT_STATUS_LOGON_FAILURE

makes sense. You shouldn't have to restart winbindd though.

> This issue is intermittent, but seems to be more likely the more DCs and sites there are in the domain. Likely some AD DS misconfiguration is involved too, as I see sometimes Winbind connecting to a DC in a wrong site, but that is also outside of my control. There is also a timeout value outside of my control that limits how long I can wait and retry for.

I'd say either fix your script to precreate ranges, as you have the
SIDs, SIDs tell you the domain, so you should be able to provision and
autorid config right from the start.

Alternatively, write a tool that only wipes the idmap cache entries in
gencache, eg net cache idmap flush or similar.

-slow

-- 
Ralph Boehme, Samba Team                https://samba.org/
Samba Developer, SerNet GmbH   https://sernet.de/en/samba/
GPG-Fingerprint   FAE2C6088A24252051C559E4AA1E9B7126399E46

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://lists.samba.org/pipermail/samba/attachments/20191018/01dd48b5/signature.sig>


More information about the samba mailing list