[Samba] Winbind and caching - idmap, DC

Alexey A Nikitin nikitin at amazon.com
Fri Oct 18 18:45:42 UTC 2019


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.

> > * 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. 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. 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, 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. 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

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.

One more thing to note is that Windows machines have zero issue in this situation. One reason for that is we don't have to fiddle with idmap at all, and we can just use SID directly to set up the necessary configurations for the user, but the other is that AFAIK Windows NetLogon service (at least according to the MS docs) actually caches the last DC it was using, and on start tries to re-use it, going into DC location only if either it cannot connect to the cached DC or that DC on connection reports that the client site has changed and it should locate a different, closer DC.

Thanks!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.samba.org/pipermail/samba/attachments/20191018/be25dd91/signature.sig>


More information about the samba mailing list