IDMAP_SCRIPT(8)

πŸ’… IDMAP_SCRIPT(8) β€” like, the winbind idmap_script backend bestie ✨

okay so real quick, this is a System Administration tools page, and it's all about idmap_script β€” Samba's whole idmap_script backend for Winbind. buckle up πŸŽ€


🌸 NAME 🌸

idmap_script β€” literally Samba's idmap_script Backend for Winbind. that's the whole vibe. πŸ’–


✨ DESCRIPTION ✨

so the idmap_script plugin is a substitute for the idmap_tdb2 backend that winbindd uses for storing SID/uid/gid mapping tables in clustered environments with Samba and CTDB. it's a read only backend that uses a script to perform the mapping. no cap 🫢

it was developed out of the idmap_tdb2 back end, and here's the thing β€” it does not store SID/uid/gid mappings in a TDB, because the winbind_cache tdb will store the mappings once they are provided. so like, the caching is somebody else's job, and honestly? slay, division of labour πŸ’…


🌈 IDMAP OPTIONS 🌈

  • range = low - high β€” defines the available matching uid and gid range that the backend is authoritative for. like, this is your turf, bestie πŸ‘‘
  • script β€” this option can be used to configure an external program for performing id mappings. yes, you're outsourcing the mapping. main character delegation energy fr fr ✨

πŸ¦‹ IDMAP SCRIPT πŸ¦‹

the script idmap backend supports an external program for performing id mappings through the /etc/samba/smb.conf option idmap config * : script β€” or its deprecated legacy form idmap : script.

⚠️ heads up: that legacy form is deprecated. iykyk. use the first one 🫢

the script should accept the following command line options:

SIDTOID S-1-xxxx
IDTOSID UID xxxx
IDTOSID GID xxxx
IDTOSID XID xxxx

and it should return one of the following responses as a single line of text:

UID:yyyy
GID:yyyy
XID:yyyy
SID:ssss
ERR:yyyy

so what's XID about? it indicates that the ID returned should be both a UID and a GID. that is, it requests an ID_TYPE_BOTH, but β€” and this is important β€” it's ultimately up to the script whether or not it can honor that request 😭 it can choose to return a UID or a GID mapping only. the script is the boss here, periodt.


🌟 EXAMPLES 🌟

this example shows how script is used as the default idmap backend using an external program via the script parameter:

[global]
idmap config * : backend = script
idmap config * : range = 1000000-2000000
idmap config * : script = /usr/local/samba/bin/idmap_script.sh

and this shows a simple script to partially perform the task:

#!/bin/sh
#
# Uncomment this if you want some logging
#echo $@ >> /tmp/idmap.sh.log
if [ "$1" == "SIDTOID" ]
then
     # Note. The number returned has to be within the range defined
     #echo "Sending UID:1000005" >> /tmp/idmap.sh.log
     echo "UID:1000005"
     exit 0
else
     #echo "Sending ERR: No idea what to do" >> /tmp/idmap.sh.log
     echo "ERR: No idea what to do"
     exit 1
fi

okay so clearly, this script is not enough πŸ’€ it should probably use wbinfo to determine if an incoming SID is a user or group SID, and then look up the mapping in a table β€” or use some other mechanism for mapping SIDs to UIDs and etc. like, do the actual work bestie πŸ™ˆ

⚠️ please be aware: the script is called with the _NO_WINBINDD environment variable set to 1. this prevents recursive calls into winbind from the script β€” both via explicit calls to wbinfo and via implicit calls via nss_winbind. for example, a call to ls -l could trigger such an infinite recursion. and no, an infinite recursion is not the cute kind of loop 😭

it is safe to call wbinfo -n and wbinfo -s from within an idmap script 🫢 to do so, the script must unset the _NO_WINBINDD environment variable right before the call to wbinfo, and set it to 1 again right after wbinfo has returned, to protect against the recursion. tricky but iconic. 🌸


πŸ‘‘ AUTHOR πŸ‘‘

the original Samba software and related utilities were created by Andrew Tridgell. Samba is now developed by the Samba Team as an Open Source project similar to the way the Linux kernel is developed. legends only, honestly πŸ«ΆπŸ’œ


k bye bestie, go map those SIDs responsibly πŸ§šπŸ’– β€” this was Samba 4.23.8 from 05/28/2026, and that's the whole IDMAP_SCRIPT(8) tea β˜•βœ¨

πŸ“¦ where this page comes from