Ldap – How to force folders created in a subdirectory to be owned by a user’s secondary group

ldappermissionssamba

I have setup a Samba share on Ubuntu 12.04 for our finance team, and they access it via Windows 7 and Mac OS X. They mount the share using their LDAP credentials. All of our LDAP users have "employees" as their primary group, and the finance team belongs to a secondary group named "finance".

When any of the finance team members create a folder within the Samba share, the folder's group defaults to "employees". How can I force all files and folders created on the share to have the group set to "finance"?

Best Answer

For share foo, with path /bar/foo, the following in your smb.conf file should do it:

[foo]
        path = /bar/foo
        force create mode = 0020
        force directory mode = 0030
        force group = +finance

The mode statements are to ensure that all directories and files created via samba are group-writeable: it's no good just being group-owned by the right group if that group has no privileges to do anything.