UNIX and Windows Accounts in Zimbra LDAP and Zimbra Admin UI: Difference between revisions
(added ldap passwd sync = yes)
|Line 156:||Line 156:|
security = user
security = user
encrypt passwords = true
encrypt passwords = true
passdb backend = ldapsam:ldap://gregzimbra1.zimbra.com/
passdb backend = ldapsam:ldap://gregzimbra1.zimbra.com/
ldap admin dn = "uid=zimbra,cn=admins,cn=zimbra"
ldap admin dn = "uid=zimbra,cn=admins,cn=zimbra"
Revision as of 18:40, 30 April 2007
This document describes how you can configure Zimbra Collaboration Server (ZCS) and Samba to act as a primary domain controller (PDC) that uses LDAP (Lightweight Directory Access Protocol) as a central password database for authenticating users on Linux and Windows desktops. The motivation behind this document is the need to seamlessly integrate ZCS into corporate network environment based entirely on Open Source server software. This functionality is achieved by configuring Zimbra LDAP to act as a central user database for PAM (Pluggable Authentication Modules), NSS (Name Service Switch), and for Samba's ldapsam password backend. The document also describes Zimbra Admin Extensions that allow managing OS and Samba accounts, groups and domains through Zimbra Admin UI.
The setup described in this document is not the only possible way to make Samba and Zimbra use the same user database for authentication. There are multiple other ways to achieve similar functionality, and it is recommended that you explore Zimbra WIKI at http://wiki.zimbra.com to see if another solution is a better fit for your needs. However, this solution is the only solution that allows network administrators to manage Windows user accounts and groups using Zimbra Admin UI. It is also highly recommended to get familiar with Zimbra, Samba, LDAP and PAM, before you start the installation. Particularly helpful are the following sources of information:
- LDAP Authentication HOWTO http://ldots.org/ldap/
- Authenticating with LDAP http://imaginator.com/~simon/ldap/
- pam.d(5) man page (explains syntax of pam.d configuration files which you will have to edit during the installation) http://www.die.net/doc/linux/man/man5/pam.d.5.html
- PAM FAQ http://www.kernel.org/pub/linux/libs/pam/FAQ
- The Official Samba-3 HOWTO and Reference Guide http://us3.samba.org/samba/docs/man/Samba-HOWTO-Collection/
- Zimbra Documentation http://www.zimbra.com/products/documentation.html
This document is intended mainly for network administrators who are faced with the task of integrating multiple OpenSource software packages to support a corporate network. The author assumes that the reader has basic knowledge of Linux/Unix OS, is capable of using a text editor and is at least vaguely familiar with Zimbra, Samba, LDAP and PAM. If these four words sound foreign to you, please take some time to look at the aforementioned sources of helpful information, or even better – have them open in separate tabs in Firefox on your second monitor while you are following the directions in this document ;)
How this guide is organized:
Part 1 describes what software you need to download and install
Part 2 describes how to configure Zimbra LDAP and Zimbra Admin to store information required by Linux password backend and allow managing Samba and Posix accounts via Zimbra Admin.
Part 3 describes how to configure Samba server to use Zimbra LDAP as a source of user information and as a Primary Domain Controller
Part 4 describes how to configure a Linux server to use Zimbra LDAP as a central source of user information.
- First, Install Zimbra Collaboration Suite (it can be an Open Source or a Network Edition) following Zimbra Installation guides that you can download from the Zimbra website (http://www.zimbra.com/products/documentation.html). Make note of the root LDAP password that is selected during the installation, you will need it to configure ldapsam, pam_ldap and nss_ldap.
- If you have an existing functioning ZCS server, you can use it instead of a new one, but make sure to back up all your data and that you know your LDAP root password (this password was created during ZCS installation). This setup works with single- as well as with multi-server Zimbra setups.
- Download ZimbraPosixAccount, ZimbraSamba and ZimbraLDAPUtils extensions for your version of ZCS from the Zimbra Gallery (http://gallery.zimbra.com). Note that these extensions are different for ZCS 4.5.x and ZCS 5.x.
Installing Zimbra LDAP Utils extension
Note: Zimbra LDAP Utils extension is included with ZCS 4.5.5. If you have ZCS 4.5.5 or later, you may skip this step.
- Download Zimbra LDAP utils server extension from Zimbra Gallery 
- Log in to your Zimbra mail server, make sure you are root. If you have a multi-server setup, this is the server that runs the mailbox service. Create folder /opt/zimbra/lib/ext/zimbraldaputils. Make sure that the folder's owner is root:root and the access mod is 0755.
- Extract zimbraldaputils.jar file from ZimbraLDAPUtils.zip and put it into /opt/zimbra/lib/ext/zimbraldaputils/zimbraldaputils.jar
- Restart tomcat on the Zimbra mail server (this can be done by running zmcontrol stop / zmcontrol start as zimbra user).
Installing ZimbraPosixAccount and ZimbraSamba extensions for Zimbra Admin
- Download zimbra_posixaccount  Admin extension from Zimbra Gallery 
- Download zimbra_samba  Admin extension from Zimbra Gallery 
- Extract files from ZimbraPosixAccount.zip to a folder on your desktop computer, open zimbra_posixaccount folder and edit config_template.xml.
- Edit ldapSuffix property in config_template.xml. This property is the path in your LDAP tree where all Linux and Samba user information will be stored. This can be the name of your primary email domain written in the ldap syntax. E.g. if your domain is mycompany.com, then ldapSuffix will be
in this example I will use the domain gregzimbra1.zimbra.com, which is the name of my Ubuntu Linux machine running inside a VMWare instance, hence my ldapSuffix is
- Edit uidBase property in config_template.xml. uidBase is the base for creating Linux user IDs for user accounts that will be stored in LDAP. The first account that you will create through Zimbra Admin UI will have user ID = uidBase+1. If you already have user accounts in your current password database (most likely /etc/passwd) it is recommended that you set this value higher than the maximum existing user account.
- Edit gidBase property in config_template.xml. gidBase is the base for creating Linux group IDs for groups that will be stored in LDAP. The first group that you will create through Zimbra Admin UI will have group ID = gidBase+1.
- Zip all the files that are in zimbra_posixaccount folder into zimbra_posixaccount.zip together with modified config_template.xml
- Log in to Zimbra Admin (https://yourserver.com:7071/zimbraAdmin) as administrator, navigate to Admin Extensions and deploy zimbra_posixaccount extension using the zimbra_posixaccount .zip file (refer to ZCS Admin Guide for more information about installing Admin Extensions)
- Extract files from ZimbraSamba.zip to a folder on your desktop computer and open config_template.xml (this file is in zimbra_samba folder along with other extension files).
- Edit ldapSuffix, uidBase and gidBase properties using the same values as you used in for zimbra_posixaccount.zip
- Zip all the files zimbra_samba folder into zimbra_samba .zip together with modified config_template.xml and deploy zimbra_samba Admin Extension.
- Reload your Zimbra Admin to initialize the extensions. When the extensions are loaded for the first time, they will check if OUs defined by ldapMachineSuffix and ldapGroupSuffix propertiesin config_template.xml files exist and create these OUs, if they do not exist.
Install Samba 3 on a Linux/Unix box. I used Samba-2.0.24 which I installed through Synaptic Package Manager on my Ubuntu 6.10 machine running inside a VMWare. If you are building Samba from sources, make sure to enable ldap support. I do not recommend installing Samba on the same machine where you installed Zimbra – better to use a separate machine.
Installing pam_ldap and nss_ldap
You need to install and configure PAM and NSS on the machine where you installed Samba. You can also install it on any Linux desktop that should use Zimbra LDAP as a user database, e.g. Linux desktops where you want to be able to log in using the same username/password that is used for Zimbra Mail.
You need to download and install pam_ldap and nss_ldap modules for your OS. I used Ubuntu Linux which has these modules available as Debian packages through Synaptic Package Manager. If you are using Synaptic Package Manager, make sure to enable community maintained repositories (see Settings->Repositories) and search for libpam-ldap and libnss-ldap packages. If you are using a different Linux, you might need to build these modules from the sources. You can find the Sources for pam_ldap and nss_ldap on http://www.padl.com.
If you are using Synaptic Package Manager to install libnss_ldap, you will be prompted for the following information:
- LDAP server Uniform Resource Identifier – enter the LDAP URL of your Zimbra LDAP server. i.e. [ldap://zimbra.mydomain.com ldap://zimbra.mydomain.com/] (in my case ldap://gregzimbra1.zimbra.com/)
- LDAP search base – enter the same value that you used for ldapSuffix property in zimbra_posixaccount and zimbra_samba extensions. I.e.: dc=yourdomain,dc=com (in my case dc=gregzimbra1,dc=zimbra,dc=com)
- LDAP account for root – enter uid=zimbra,cn=admins,cn=zimbra
- LDAP root account password – enter the LDAP root password that you selected during Zimbra installation (told you make a note of it ;) )
If you don't know the LDAP root account password, you can change it to a know value like this (as the zimbra user): zimbra@localhost:~$ zmldappasswd --root newpasswd
If you are using Synaptic Package Manager to install libpam_ldap, you will be prompted for the following information:
- LDAP Server – enter the hostname or IP address of your Zimbra LDAP server
- root login account – enter uid=zimbra,cn=admins,cn=zimbra
- root login password - enter the LDAP root password that you selected during Zimbra installation
Configuring Zimbra LDAP
Before you can configure Zimbra LDAP you need to download nis.schema and samba.schema files.
- If nis.schema file already exists in /opt/zimbra/openldap/etc/openldap/schema/ - skip to the next bullet, otherwise you need to download it. nis.schema file depends on your version of OpenLDAP. Therefore, the best way to get the correct nis.schema file is to download OpenLDAP source code from http://www.openldap.org/software/download/ for your version of OpenLDAP and take the nis.schema file from servers/slapd/schema folder in the source package. In this document I am using OpenLDAP 2.3.34 which is distributed with ZCS 4.5.4 for Ubuntu Linux.
- samba.schema file depends on the version of Samba that you will be installing. Therefore, I recommend downloading Samba source package for the latest stable version of Samba available for your server's OS and taking samba.schema from examples/LDAP folder in the source package. In this document I am using Samba 3.0.24.
Log in to the shell on your Zimbra LDAP server. If you have a multi-server setup this is the machine where ldap service is running. Copy samba.schema and nis.schema files to /opt/zimbra/openldap/etc/openldap/schema/ (or wherever your OpenLDAP schema files are if you are using a different LDAP server).
Next, edit /opt/zimbra/conf/slapd.conf.in file. You need to add these the following two lines after the last “include” statement at the top of the file:
You may also want to add these ldap indexes at the end of the file:
#indexes for PAM
index uidNumber eq index gidNumber eq index memberUID eq
#indexes for Samba
index sambaSID eq index sambaPrimaryGroupSID eq index sambaDomainName eq
an example of slapd.conf.in file is in ZimbraSamba.zip in examples/conf folder.
After you edited slapd.conf.in file and copied *.schema files to /opt/zimbra/openldap/etc/openldap/schema/, restart Zimbra services and make sure that they started successfully.
Now run the following zmprov commands as user zimbra:
>zmprov mcf +zimbraAccountExtraObjectClass posixAccount >zmprov mcf +zimbraAccountExtraObjectClass sambaSamAccount
There are many ways to configure Samba depending on what you needs are. In this example I will configure Samba to use Zimbra LDAP as password backend and to act as a primary domain controller for domain GREGZIMBRA1 and as a WINS server for my network. This configuration will allow Windows NT/XP/2000 workstations to join GREGZIMBRA1 domain as if it was an NT domain. Below is the /etc/samba/smb.conf file used in this example.
[global] workgroup = GREGZIMBRA1 netbios name = gregzimbra2 os level = 33 preferred master = yes enable privileges = yes server string = %h server (Samba, Ubuntu) wins support =yes dns proxy = no name resolve order = wins bcast hosts
log file = /var/log/samba/log.%m log level = 3 max log size = 1000 syslog only = no syslog = 0 panic action = /usr/share/samba/panic-action %d security = user encrypt passwords = true ldap passwd sync = yes passdb backend = ldapsam:ldap://gregzimbra1.zimbra.com/ ldap admin dn = "uid=zimbra,cn=admins,cn=zimbra" ldap suffix = dc=gregzimbra1,dc=zimbra,dc=com ldap group suffix = ou=groups ldap user suffix = ou=people ldap machine suffix = ou=machines obey pam restrictions = no passwd program = /usr/bin/passwd %u passwd chat = *Enter\snew\sUNIX\spassword:* %n\n *Retype\snew\sUNIX\spassword:* %n\n *password\supdated\ssuccessfully* .
domain logons = yes logon path = \\gregzimbra2.zimbra.com\%U\profile logon home = \\gregzimbra2.zimbra.com\%U logon script = logon.cmd add user script = /usr/sbin/adduser --quiet --disabled-password --gecos "" %u add machine script = /usr/sbin/adduser --shell /bin/false --disabled-password --quiet --gecos "machine account" --force-badname %u socket options = TCP_NODELAY
domain master = yes local master = yes
[homes] comment = Home Directories browseable =yes read only = No
valid users = %S
[netlogon] comment = Network Logon Service path = /var/lib/samba/netlogon guest ok = yes locking = no
[profiles] comment = Users profiles path = /var/lib/samba/profiles read only = No
[profdata] comment = Profile Data Share path = /var/lib/samba/profdata read only = No profile acls = Yes
[printers] comment = All Printers browseable = no path = /tmp printable = yes public = no writable = no create mode = 0700
[print$] comment = Printer Drivers path = /var/lib/samba/printers browseable = yes read only = yes guest ok = no
I will not attempt to explain every line in this file, so if you are interested – read the official Samba HOWTO. The key elements that are important for this example are these lines:
passdb backend = ldapsam:ldap://gregzimbra1.zimbra.com/ ldap admin dn = "uid=zimbra,cn=admins,cn=zimbra" ldap suffix = dc=gregzimbra1,dc=zimbra,dc=com ldap group suffix = ou=groups ldap user suffix = ou=people ldap machine suffix = ou=machines
- passdb backend = ldapsam:ldap://gregzimbra1.zimbra.com/ tells Samba to use ldap ass password backend and to contact Zimbra LDAP server at [ldap://gregzimbra1.zimbra.com/ ldap://gregzimbra1.zimbra.com/] .
- ldap admin dn is the same value as the root LDAP account that you entered when you were installing pam_ldap.
- ldap suffix is the name of your Zimbra domain, and it is the same value as the value of ldapSuffix property in config_template.xml files.
- ldap group suffix is the same value as the value of ldapGroupSuffix in config_template.xml files.
- ldap machine suffix is the same value as the value of ldapMachineSuffix in config_template.xml files.
- the value of ldap user suffix must be ou=people, because this is where Zimbra account records are stored in LDAP.
After you edited smb.conf file, you need to tell Samba what is the root password for ldap. On your Samba server, restart samba services (/usr/sbin/smbd and /usr/sbin/nmbd) run the following command (replace test123 with your ldap root password).
>smbpasswd -w test123
Creating Samba domain using Zimbra Admin UI
Log in to Zimbra Admin an click on Samba Domains. You should see a domain entry in the list. When Samba started up with the new smb.conf file it should have looked up the domain entry in LDAP and created it if it could not find the entry.
Configuring pam_ldap and nss_ldap
Open file /etc/libnss-ldap.conf, make sure that base is set to the same value that you chose for
ldapSuffix. It should look like this (type your root LDAP password instead of test123):
gregzimbra1,dc=zimbra,dc=com host gregzimbra1.zimbra.com binddn uid=zimbra,cn=admins,cn=zimbra bindpw test123 rootbinddn uid=zimbra,cn=admins,cn=zimbra
Make sure that host points to your Zimbra LDAP server. Next, copy /etc/libnss-ldap.conf to /etc/pam_ldap.conf, both modules have compatible syntax, so the same configuration file will work for both pam_ldap and nss_ldap.
Edit /etc/libnss-ldap.secret and make sure it contains your root LDAP password. Then, copy /etc/libnss-ldap.secret to /etc/pam_ldap.secret
Edit /etc/nsswitch.conf file. Replace these two lines:
passwd: compat group: compat
with these lines:
passwd files ldap group files ldap
this change will tell nsswitch to use ldap when it looks for uids and gids. It will first look at /etc/passwd and then at ldap. You may want to change these lines differently if you know what you are doing ;)
Edit /etc/pam.d/common-account. It should look like the following:
account sufficient pam_unix.so account sufficient pam_ldap.so
Edit /etc/pam.d/common-auth. It should look like the following:
auth sufficient pam_ldap.so auth sufficient pam_unix.so
Edit /etc/pam.d/common-password. It should look like the following:
password sufficient pam_unix.so password sufficient pam_ldap.so
Edit /etc/pam.d/common-session. It should look like the following:
session sufficient pam_unix.so session sufficient pam_ldap.so
Now you need to test whether pam_ldap and nssswitch are working correctly. Log in to Zimbra Admin UI (https://yourserver.com:7071/zimbraAdmin) as Administrator and create a couple of new user accounts. On the New Account Wizard you should see two additional steps (after “Advanced” step): Posix Account and Samba Account
Creating Linux and Samba groups using Zimbra Admin UI
Log in to Zimbra Admin UI. You should not have logged out of it anyway, because we are not done yet. Go to Posix Groups and click “New”. If you do not know what to type in group type field – type 2, this is the default value.
To test if PAM on your Samba server is reading the group information correctly from Zimbra LDAP, go back to your Samba server shell and run this command as root:
you should see the group(s) that you just created in the list that is produced.
Creating Linux and Samba users using Zimbra Admin UI
Back to the Zimbra Admin UI :). Go to Accounts and hit New, fill in the information on the first screen and follow the wizard to the Posix Account screen. Fill in all the required fields on the Posix Account screen and click Next to go to Samba Account screen. Fill in the required fields and click Finish. To test if PAM on your Samba server is reading the user password information correctly from Zimbra LDAP, go back to your Samba server shell and run this command as root:
you should see the Zimbra accounts that you just created in the list. Create a home folder for the new Zmbra user and try to change the current user to the newly created one. In this example, I create a user ubuntu2, and home folder /home/ubuntu2
root@gregzimbra2:/home/ubuntu# su - ubuntu2
Now test if Samba authenticates your new user correctly. In this example I went to the shell on my Zimbra server box and ran this command:
root@gregzimbra1:/home/ubuntu# smbclient -U ubuntu2 //gregzimbra2.zimbra.com/ubuntu2
It should prompt you for the password and then log in to ubuntu2's home folder on gregzimbra2 Samba server.
Next, log in to Zimbra Admin UI, click on Aliases and remove root@.gregzimbra1.zimbra.com alias. Then run
>smbpasswd -a root
Creating Windows NT Domain groups
Next, create “Domain Admins” group using Zimbra Admin UI, on Samba tab select Special Windows group type “Domain Admins”. Then you need to grant privileges to this group. Run the following command as root on your Samba server. Put your domain name instead of GREGZIMBRA1. More information on this topic is available in Official Samba HOWTO Reference Guide (http://us3.samba.org/samba/docs/man/Samba-HOWTO-Collection/).
> net rpc rights grant "GREGZIMBRA1\Domain Admins" SeAddUsersPrivilege SeMachineAccountPrivilege SePrintOperatorPrivilege
Adding Windows NT/2000/XP machines to Samba domain
Log in to an Windows desktop as a local administrator and join the Samba domain the same way you would be joining a Windows domain. You might need to point your Windows box to your Samba WINS server depending on how your DHCP and DNS servers are configured. Use a member of “Domain Admins” group to join the domain. After you joined the domain, verify that the machine account was added to ldap directory by running ldapsearch command. I.e. if your windows desktop machine name is gregvmxp2:
root@gregzimbra1:/home/ubuntu# /opt/zimbra/openldap/bin/ldapsearch -h gregzimbra1 | grep gregvmxp
# gregvmxp2$, machines, gregzimbra1.zimbra.com