Work In Progress

Linux - Samba ID mapping notes

Abbreviations and Definitions used

  1. uidNumber: The uidNumber attribute is used to store the User ID (UID) of a Unix user. When Samba integrates with Active Directory using RFC 2307, it leverages the uidNumber attribute to map Unix user accounts to Active Directory users.
  2. gidNumber: The gidNumber attribute is defined to store the Group ID (GID) of a Unix group. When Samba integrates with Active Directory using RFC 2307, it leverages the gidNumber attribute to map Unix groups to Active Directory groups.
  3. unixHomeDirectory: The user’s home directory.
  4. loginShell: The user’s shell.

Overview:

What is ID mapping and why it is needed in Linux?

ID mapping backends are essential for Samba servers (both Domain Controllers and Member servers), enabling the translation of Windows Security Identifiers (SIDs) and Relative Identifiers (RIDs) into UNIX user IDs (UIDs) and group IDs (GIDs). This ensures proper management and ownership of resources in a mixed Windows and UNIX environment.

Without ID mapping, Windows users and groups would be unknown to Linux, and for his reason, unable to access resources on a Linux server.

ID Mapping in a DC

ID-mapping in a Samba Domain Controller (DC) is managed using a dedicated backend. The Samba DC uses an internal database, idmap.ldb, to manage these mappings. The UIDs and GIDs used in this id-map are in the 3000000+ range. This mapping is done internally by Samba in the DC, and it's transparent to you.

In this internal database there are a couple of objects that deserve special attention:

root@dc1:~# wbinfo --uid-info 0
MAD\administrator:*:0:10000::/home/MAD/administrator:/bin/false 
root@dc1:~# wbinfo --uid-info 3000005
MAD\domain admins:*:3000005:3000005::/home/MAD/domain admins:/bin/false
root@dc1:~# wbinfo --gid-info 3000005
MAD\domain admins:x:3000005:

In the member servers of an Active Directory, typically either 'RID' or 'AD' id-mappings are used. More on this later. If AD id-mapping is used in your member servers, RFC 2307 attributes (also called Unix Attributes) need to be populated for every user and group you create in the AD. More on this later. Two of these attributes are uidNumber and gidNumber, and when the mapping is done, they will directly translate to UIDs and GIDs in Linux machines.

If RFC 2307 attributes are used because you use AD id-mapping, there is an option to use this mapping for the DCs instead of the internal idmap.ldb. In this case, you should include this in in smb.conf file.:

idmap_ldb:use rfc2307  = yes

If you are adding rfc2307 attributes to the AD, AND ( you are using the DC as a fileserver, which is not recommended, needing to sync files with other ad-idmapped member server OR needing users to login into the DC with different home folders or shells ), there really is no need for this setting.

Learn why this is hard to recommend except in these very exceptional circumstances as described before, so please make sure you don’t have it in your smb.conf unless you have a very clear idea of what this means.

Using this configuration option in a DC will mean that, in order not to break the ‘ID_TYPE_BOTH’ feature of the “special” objects like 'Domain Admins', neither 'Administrator' nor 'Domain Admins' should have a uidNumber and gidNumber respectively.

Subsequently, as no gidNumber has been assigned to ‘Domain Admins’ it means nothing to a member server with AD idmapping. This adds the complexity of having to create an extra group, for example ‘Unix Admins’, assign it a gidNumber, make it a member of ‘Domain Admins’ and use this new group where you would use ‘Domain Admins’ in the member server.

RID ID Mapping in a member server

AD ID Mapping in a member server


Caponato's Samba notebook. Start here or else Main menu