(First submitted by idra (a) samba.org)
Samba and the Editposix/Trusted Ldapsam extension
The ldapsam:editposix extension is based on the ldapsam:trusted optimization. The ldapsam:trusted optimization has been developed as a performance optimization for server that uses ldap as user and group account storage. This optimization _requires_ that all samba users and group accounts store their posix account information in the ldap tree.
The ldapsam:editposix extension has been created with the aim of making it easier to configure samba for use with an ldap server, by providing means to add the posix accounts and groups on the LDAP server without the need to use external scripts.
To further help admins we introduced the net sam provision command that helps creating the basic accounts and groups need to make smbd run.
A running winbind daemon is required to use ldapsam:editposix EVEN ON A SAMBA PDC.
Using the ldap idmap backend is strongly advised too.
Basic LDAP configuration
We will not get into the specific of LDAP configuration. To use editposix you need a very basic tree.
Here it is an example base ldif to be loaded on your server to create the basic tree structure:
dn: dc=samba,dc=org objectClass: top objectClass: dcObject objectClass: organization o: samba.org dc: samba dn: cn=admin,dc=samba,dc=org objectClass: simpleSecurityObject objectClass: organizationalRole cn: admin description: LDAP administrator userPassword: secret dn: ou=users,dc=samba,dc=org objectClass: top objectClass: organizationalUnit ou: users dn: ou=groups,dc=samba,dc=org objectClass: top objectClass: organizationalUnit ou: groups dn: ou=idmap,dc=samba,dc=org objectClass: top objectClass: organizationalUnit ou: idmap dn: ou=computers,dc=samba,dc=org objectClass: top objectClass: organizationalUnit ou: computers
Download it Basic_LDAP_configuration.ldif
you need to properly configure smb.conf before running any daemon or command.
Here is the bare minimum options to set in smb.conf:
workgroup = MYGROUP
encrypt passwords = true passdb backend = ldapsam
ldap admin dn = cn=admin,dc=samba,dc=org ldap delete dn = yes ldap group suffix = ou=groups ldap machine suffix = ou=computers ldap user suffix = ou=users ldap suffix = dc=samba,dc=org
Old idmap syntax (pre 3.0.25):
ldap idmap suffix = ou=idmap idmap backend = ldap:"ldap://localhost" idmap uid = 50000-500000 idmap gid = 50000-500000
New idmap syntax (post 3.0.25):
idmap domains = DEFAULT idmap config DEFAULT:backend = ldap idmap config DEFAULT:readonly = no idmap config DEFAULT:default = yes idmap config DEFAULT:ldap_base_dn = ou=idmap,dc=samba,dc=org idmap config DEFAULT:ldap_user_dn = cn=admin,dc=samba,dc=org idmap config DEFAULT:ldap_url = ldap://localhost idmap config DEFAULT:range = 50000-500000
idmap alloc backend = ldap idmap alloc config:ldap_base_dn = ou=idmap,dc=samba,dc=org idmap alloc config:ldap_user_dn = cn=admin,dc=samba,dc=org idmap alloc config:ldap_url = ldap://localhost idmap alloc config:range = 50000-500000
A quick setup
Do not run any daemon until told, use a fresh install or wipe out any previously created tdb before starting.
To quickly set up and test this feature follow these steps as root:
Configure and run your ldap server, you may use the above base ldif as a starting point. Make sure the defined ldap admin works correctly.
Add the ldap admin password to the samba secrets database:
# smbpasswd -w secret
NOTE: If you are using the new style idmap syntax (post 3.0.25) you will need to store the password into a security store. (See man idmap_ldap)
# net idmap secret DOMAIN <password> # net idmap secret alloc <password>
Start winbindd only.
# /etc/init.d/winbindd start
provision the tree:
# net sam provision
Should the command returns: "Unable to allocate a new gid to create Domain Admins group" then make sure idmap is properly configured and the idmap range is large enough to hold the predicted number of unique users+groups you will have in your system life time. On a new system you should never incur into this error, in case you have to increase the idmap range in a production system, just increase the highest value, NEVER change the lowest value.
Create the default windows built-in groups to avoid this: Bug 6537.
# net sam createbuiltingroup Administrators # net sam createbuiltingroup Users # net sam createbuiltingroup Guests
Give a password to the newly created Administrator user enabling it.
# smbpasswd Administrator New SMB password: Retype new SMB password:
Now start also nmbd and smbd:
# /etc/init.d/nmbd start # /etc/init.d/smbd start
Grant yourself some privileges:
# net rpc rights grant Administrator SeAddUsersPrivilege -U Administrator # net rpc rights grant Administrator SeMachineAccountPrivilege -U Administrator
Managing your DB
At this point you will be able to connect from any windows client or use any samba tool to manage your users groups and machines with the Administrator user.