Это старая версия документа.
Содержание
Samba как контроллер домена
Хотя он не может представлять из себя первичный контроллер домена (PDC) Active Directory, Samba сервер может быть настроен как контроллер домена Windows NT4. Основным преимуществом такой конфигурации является возможность централизовать учетные записи пользователей и машин. Кроме того Samba может использовать различные базы данных для хранения информации о пользователях.
Первичный контроллер домена
В этом разделе рассматривается настройка Samba в качестве первичного контроллера домена (PDC) с использованием smbpasswd в качестве хранилища данных.
1. Первым делом установим Samba и libpam-smbpass для синхронизации учетных записей пользователей, введя в терминале:
sudo apt-get install samba libpam-smbpass
2. Далее настроим Samba редактированием /etc/samba/smb.conf. Режим безопасности следует установить user, а рабочую группу следует назвать в соответствии с именем вашей организации:
workgroup = EXAMPLE ... security = user
3. В закомментированной секции "Domains" добавьте или раскомментируйте следующее:
domain logons = yes logon path = \\%N\%U\profile logon drive = H: logon home = \\%N\%U logon script = logon.cmd add machine script = sudo /usr/sbin/useradd -N -g machines -c Machine -d /var/lib/samba -s /bin/false %u
domain logons: заставляет сервис netlogon взаимодействовать с Samba как с контроллером домена.
logon path: помещает пользовательский профиль Windows в его домашний каталог. Также существует возможность настроить разделяемый ресурс [profiles], поместив все профили в один каталог.
logon drive: определяет локальный путь для домашнего каталога.
logon home: определяет местоположение домашнего каталога.
logon script: определяет сценарий, который должен быть выполнен один раз при входе пользователя. Сценарий должен быть помещен в разделяемый ресурс [netlogon].
add machine script: сценарий, который будет автоматически запущен при создании доверительной учетной записи машины при добавлении рабочей станции в домен.
В этом примере требуется создать группу machines с использованием утилиты addgroup. Подробности смотрите в разделе Добавление и удаление пользователей.
4. Раскомментируйте ресурс [homes] чтобы указать домашний каталог для входа:
[homes] comment = Home Directories browseable = no read only = no create mask = 0700 directory mask = 0700 valid users = %S
5. При настройке Samba в качестве доменного контроллера требуется настроить ресурс [netlogon]. Для включения ресурса раскомментируйте:
[netlogon] comment = Network Logon Service path = /srv/samba/netlogon guest ok = yes read only = yes share modes = no
6. Теперь создадим каталог netlogon и пустой (пока) файл сценария logon.cmd:
sudo mkdir -p /srv/samba/netlogon sudo touch /srv/samba/netlogon/logon.cmd
Вы можете ввести любые обычные команды сценария входа Windows в logon.cmd для настройки клиентского окружения.
Restart Samba to enable the new domain controller:
sudo restart smbd sudo restart nmbd
Lastly, there are a few additional commands needed to setup the appropriate rights.
With root being disabled by default, in order to join a workstation to the domain, a system group needs to be mapped to the Windows Domain Admins group. Using the net utility, from a terminal enter:
sudo net groupmap add ntgroup="Domain Admins" unixgroup=sysadmin rid=512 type=d
Change sysadmin to whichever group you prefer. Also, the user used to join the domain needs to be a member of the sysadmin group, as well as a member of the system admin group. The admin group allows sudo use.
If the user does not have Samba credentials yet, you can add them with the smbpasswd utility, change the sysadmin username appropriately:
sudo smbpasswd -a sysadmin
Also, rights need to be explicitly provided to the Domain Admins group to allow the add machine script (and other admin functions) to work. This is achieved by executing:
net rpc rights grant -U sysadmin "EXAMPLE\Domain Admins" SeMachineAccountPrivilege \ SePrintOperatorPrivilege SeAddUsersPrivilege SeDiskOperatorPrivilege \ SeRemoteShutdownPrivilege
You should now be able to join Windows clients to the Domain in the same manner as joining them to an NT4 domain running on a Windows server.
Резервный контроллер домена
With a Primary Domain Controller (PDC) on the network it is best to have a Backup Domain Controller (BDC) as well. This will allow clients to authenticate in case the PDC becomes unavailable.
When configuring Samba as a BDC you need a way to sync account information with the PDC. There are multiple ways of accomplishing this scp, rsync, or by using LDAP as the passdb backend.
Using LDAP is the most robust way to sync account information, because both domain controllers can use the same information in real time. However, setting up a LDAP server may be overly complicated for a small number of user and computer accounts. See Samba and LDAP for details.
First, install samba and libpam-smbpass. From a terminal enter:
sudo apt-get install samba libpam-smbpass
Now, edit /etc/samba/smb.conf and uncomment the following in the [global]:
workgroup = EXAMPLE ... security = user
In the commented Domains uncomment or add:
domain logons = yes domain master = no
Make sure a user has rights to read the files in /var/lib/samba. For example, to allow users in the admin group to scp the files, enter:
sudo chgrp -R admin /var/lib/samba
Next, sync the user accounts, using scp to copy the /var/lib/samba directory from the PDC:
sudo scp -r username@pdc:/var/lib/samba /var/lib
Replace username with a valid username and pdc with the hostname or IP Address of your actual PDC.
Finally, restart samba:
sudo restart smbd sudo restart nmbd
You can test that your Backup Domain controller is working by stopping the Samba daemon on the PDC, then trying to login to a Windows client joined to the domain.
Another thing to keep in mind is if you have configured the logon home option as a directory on the PDC, and the PDC becomes unavailable, access to the user's Home drive will also be unavailable. For this reason it is best to configure the logon home to reside on a separate file server from the PDC and BDC.
Ссылки
For in depth Samba configurations see the Samba HOWTO Collection
The guide is also available in printed format.
O'Reilly's Using Samba is also a good reference.
Chapter 4 of the Samba HOWTO Collection explains setting up a Primary Domain Controller.
Chapter 5 of the Samba HOWTO Collection explains setting up a Backup Domain Controller.
The Ubuntu Wiki Samba page.