OpenLDAP сервер Сравнение версий

Различия

Здесь показаны различия между двумя версиями данной страницы.

Ссылка на это сравнение

Предыдущая версия справа и слева Предыдущая версия
Следующая версия
Предыдущая версия
wiki:руководство_по_ubuntu_server:авторизация_по_сети:openldap_server [2012/06/12 13:01]
[TLS]
wiki:руководство_по_ubuntu_server:авторизация_по_сети:openldap_server [2013/02/10 08:17] (текущий)
орфография; </code>
Строка 58: Строка 58:
 <​note>​Ubuntu теперь использует метод slapd-config для настройки slapd и данное руководство это отражает.</​note>​ <​note>​Ubuntu теперь использует метод slapd-config для настройки slapd и данное руководство это отражает.</​note>​
  
-Во время установки у вас будет запрос на информацию об администраторе. Это LDAP данные для rootDN вашего экземпляра базы данных. По умолчанию этот пользовательский DN **cn=admin,​dc=example,​dc=com**. Также по умолчанию не создаеется административного пользователя для базы данных slapd-config и вы, следовательно,​ будете вынуждены использовать внешнюю авторизацию LDAP для доступа к ней. Мы рассмотрим как это делается позднее.+Во время установки у вас будет запрос на информацию об администраторе. Это LDAP данные для rootDN вашего экземпляра базы данных. По умолчанию этот пользовательский DN **cn=admin,​dc=example,​dc=com**. Также по умолчанию не создается административного пользователя для базы данных slapd-config и вы, следовательно,​ будете вынуждены использовать внешнюю авторизацию LDAP для доступа к ней. Мы рассмотрим как это делается позднее.
  
 Некоторые классические схемы (cosine, nis, inetorgperson) выпускаются теперь для slapd. Это также включает базовую (core) схему, которая предполагается для любой рабочей схемы. Некоторые классические схемы (cosine, nis, inetorgperson) выпускаются теперь для slapd. Это также включает базовую (core) схему, которая предполагается для любой рабочей схемы.
Строка 86: Строка 86:
 <​note>​Не редактируйте базу slapd-config напрямую. Вносите изменения через протокол LDAP (утилитами).</​note>​ <​note>​Не редактируйте базу slapd-config напрямую. Вносите изменения через протокол LDAP (утилитами).</​note>​
  
-  ** Здесь ​ппоказано как выглядит дерево slapd-config через LDAP протокол: ​+  ** Здесь показано как выглядит дерево slapd-config через LDAP протокол: ​
 <​code>​sudo ldapsearch -Q -LLL -Y EXTERNAL -H ldapi:/// -b cn=config dn <​code>​sudo ldapsearch -Q -LLL -Y EXTERNAL -H ldapi:/// -b cn=config dn
 dn: cn=config dn: cn=config
Строка 393: Строка 393:
 </​code>​ </​code>​
  
-Создаем каталог,​ устанавливаем файл настроек базы данных и перегружаем рофиль apparmor:+Создаем каталог,​ устанавливаем файл настроек базы данных и перегружаем ​профиль apparmor:
 <​code>​ <​code>​
     sudo -u openldap mkdir /​var/​lib/​ldap/​accesslog     sudo -u openldap mkdir /​var/​lib/​ldap/​accesslog
Строка 563: Строка 563:
   ** Создаем секретный ключ Центра сертификатов:​   ** Создаем секретный ключ Центра сертификатов:​
 <​code>​sudo sh -c "​certtool --generate-privkey > /​etc/​ssl/​private/​cakey.pem"</​code>​ <​code>​sudo sh -c "​certtool --generate-privkey > /​etc/​ssl/​private/​cakey.pem"</​code>​
-  ** Создаем временный файл /​etc/​ssl/​ca.info для оределения CA:+  ** Создаем временный файл /​etc/​ssl/​ca.info для определения CA:
 <​code>​ <​code>​
     cn = Example Company     cn = Example Company
Строка 618: Строка 618:
 <​note>​LDAP поверх TLS/SSL (%%ldaps://​%%) осуждается в пользу **StartTLS**. Последний опирается на существующую LDAP сессию (прослушивание TCP порта 389), защищенную TLS/SSL в то время как LDAPS, подобно HTTPS, является другим защищенным-с-самого-начала протоколом,​ который работает через TCP порт 636.</​note>​ <​note>​LDAP поверх TLS/SSL (%%ldaps://​%%) осуждается в пользу **StartTLS**. Последний опирается на существующую LDAP сессию (прослушивание TCP порта 389), защищенную TLS/SSL в то время как LDAPS, подобно HTTPS, является другим защищенным-с-самого-начала протоколом,​ который работает через TCP порт 636.</​note>​
  
-Tighten up ownership and permissions:+Сужаем права на владение и доступ:
 <​code>​ <​code>​
 sudo adduser openldap ssl-cert sudo adduser openldap ssl-cert
Строка 625: Строка 625:
 sudo chmod o-r /​etc/​ssl/​private/​ldap01_slapd_key.pem sudo chmod o-r /​etc/​ssl/​private/​ldap01_slapd_key.pem
 </​code>​ </​code>​
-Restart ​OpenLDAP:+ 
 +Перегружаем ​OpenLDAP:
 <​code>​sudo service slapd restart</​code>​ <​code>​sudo service slapd restart</​code>​
  
-Check your host's logs (/​var/​log/​syslog) ​to see if the server has started properly.+Проверьте ваши системные журналы ​(/​var/​log/​syslog) ​чтобы убедиться что сервер запустился правильно.
  
 ====Репликация и TLS==== ====Репликация и TLS====
  
-If you have set up replication between serversit is common practice to encrypt ​(StartTLS) ​the replication traffic to prevent evesdroppingThis is distinct from using encryption with authentication as we did aboveIn this section we will build on that TLS-authentication work.+Если вы настроили репликацию между серверамисуществует общая практика шифровать ​(StartTLS) ​трафик репликации для исключения прослушиванияЛучше всего использовать шифрование с аутентификацией как мы делали вышеВ этой секции мы будем основываться на проделанной работе по TLS-аутентификации.
  
-The assumption here is that you have set up replication between Provider and Consumer according to Replication and have configured ​TLS for authentication on the Provider by following ​TLS.+Здесь предполагается,​ что вы настроили репликацию между Поставщиком и Провайдером в соответствии с [[#​репликация|секцией Репликация]] и настроили ​TLS для аутентификации на Поставщике следуя инструкциям [[#​tls|секции ​TLS]].
  
-As previously statedthe objective ​(for uswith replication is high availablity for the LDAP serviceSince we have TLS for authentication on the Provider we will require the same on the Consumer. In addition to thishowever, we want to encrypt replication trafficWhat remains to be done is to create a key and certificate for the Consumer and then configure accordinglyWe will generate the key/​certificate on the Providerto avoid having to create another CA certificateand then transfer the necessary material over to the Consumer. +Как утверждалось ранеецель ​(для насрепликации - это высокая доступность сервиса ​LDAP. Поскольку мы имеем ​TLS для аутентификации на Поставщикемы нуждаемся в этом и на ПотребителеОднако в дополнение к этому мы хотим зашифровать трафик репликацииЧто остается сделатьтак это создать ключ и сертификат для Потребителя и затем провести соответствующую настройку. Мы создадим ключ и сертификат на Поставщике для предотвращения создания другого Центра сертификатова затем перенесем необходимые данные на Потребителя.
- +
-    On the Provider, +
- +
-    Create a holding directory (which will be used for the eventual transfer) and then the Consumer'​s private key:+
  
 +  ** **На Поставщике**:​
 +Создаем промежуточный каталог (который будет использоваться для переноса) и затем секретный ключ Потребителя:​
 +<​code>​
     mkdir ldap02-ssl     mkdir ldap02-ssl
     cd ldap02-ssl     cd ldap02-ssl
Строка 647: Строка 647:
     --bits 1024 \     --bits 1024 \
     --outfile ldap02_slapd_key.pem     --outfile ldap02_slapd_key.pem
- +</​code>​ 
-    ​Create an info file, ldap02.info, for the Consumer server, adjusting it's values accordingly+Создаем информационный файл ​ldap02.info ​для сервера Потребителя;​ подставляйте свои соответствующие значения
 +<​code>​
     organization = Example Company     organization = Example Company
     cn = ldap02.example.com     cn = ldap02.example.com
Строка 656: Строка 656:
     signing_key     signing_key
     expiration_days = 3650     expiration_days = 3650
- +</​code>​ 
-    ​Create the Consumer'​s certificate+Создаем сертификат Потребителя
 +<​code>​
     sudo certtool --generate-certificate \     sudo certtool --generate-certificate \
     --load-privkey ldap02_slapd_key.pem \     --load-privkey ldap02_slapd_key.pem \
Строка 665: Строка 665:
     --template ldap02.info \     --template ldap02.info \
     --outfile ldap02_slapd_cert.pem     --outfile ldap02_slapd_cert.pem
- +</​code>​ 
-    Get a copy of the CA certificate+Получаем копию сертификата ​CA: 
- +<​code>​cp /​etc/​ssl/​certs/​cacert.pem .</​code>​ 
-    ​cp /​etc/​ssl/​certs/​cacert.pem . +Все готовоТеперь переносим каталог ​ldap02-ssl ​на сервер ПотребителяЗдесь мы использовали ​scp (данные изменяем соответственно): 
- +<​code>​
-    We're doneNow transfer the ldap02-ssl ​directory to the ConsumerHere we use scp (adjust accordingly): +
     cd ..     cd ..
     scp -r ldap02-ssl user@consumer:​     scp -r ldap02-ssl user@consumer:​
 +</​code>​
  
-    On the Consumer, +  ** **На Потребителе**:​ 
- +Настраиваем ​TLS аутентификацию
-    ​Configure ​TLS authentication+<​code>​
     sudo apt-get install ssl-cert     sudo apt-get install ssl-cert
     sudo adduser openldap ssl-cert     sudo adduser openldap ssl-cert
Строка 686: Строка 684:
     sudo chmod g+r /​etc/​ssl/​private/​ldap02_slapd_key.pem     sudo chmod g+r /​etc/​ssl/​private/​ldap02_slapd_key.pem
     sudo chmod o-r /​etc/​ssl/​private/​ldap02_slapd_key.pem     sudo chmod o-r /​etc/​ssl/​private/​ldap02_slapd_key.pem
- +</​code>​ 
-    ​Create the file /​etc/​ssl/​certinfo.ldif ​with the following contents ​(adjust accordingly): +Создаем файл ​/​etc/​ssl/​certinfo.ldif ​со следующим содержимым ​(исправляйте соответственно): 
 +<​code>​
     dn: cn=config     dn: cn=config
     add: olcTLSCACertificateFile     add: olcTLSCACertificateFile
Строка 698: Строка 696:
     add: olcTLSCertificateKeyFile     add: olcTLSCertificateKeyFile
     olcTLSCertificateKeyFile:​ /​etc/​ssl/​private/​ldap02_slapd_key.pem     olcTLSCertificateKeyFile:​ /​etc/​ssl/​private/​ldap02_slapd_key.pem
 +</​code>​
 +Настраиваем базу slapd-config:​
 +<​code>​sudo ldapmodify -Y EXTERNAL -H ldapi:/// -f certinfo.ldif</​code>​
 +Настраиваем /​etc/​default/​slapd как на Поставщике (SLAPD_SERVICES).
  
-    Configure the slapd-config database+  ** **На Потребителе**
- +Настраиваем ​TLS для репликации на стороне ПотребителяИзменяем существующий атрибут **olcSyncrepl** присоединяя некоторые ​TLS опцииДелая этомы увидим в первый раз как изменять значения атрибутов.
-    sudo ldapmodify -Y EXTERNAL -H ldapi:/// -f certinfo.ldif +
- +
-    Configure /​etc/​default/​slapd as on the Provider (SLAPD_SERVICES). +
- +
-    On the Consumer, +
- +
-    Configure ​TLS for Consumer-side replicationModify the existing ​olcSyncrepl ​attribute by tacking on some TLS optionsIn so doingwe will see, for the first time, how to change an attribute'​s value(s). +
- +
-    Create the file consumer_sync_tls.ldif with the following contents:+
  
 +Создаем файл consumer_sync_tls.ldif со следующим содержимым:​
 +<​code>​
     dn: olcDatabase={1}hdb,​cn=config     dn: olcDatabase={1}hdb,​cn=config
     replace: olcSyncRepl     replace: olcSyncRepl
Строка 718: Строка 713:
      ​schemachecking=on type=refreshAndPersist retry="​60 +" syncdata=accesslog      ​schemachecking=on type=refreshAndPersist retry="​60 +" syncdata=accesslog
      ​starttls=critical tls_reqcert=demand      ​starttls=critical tls_reqcert=demand
 +</​code>​
 +Дополнительные опции определяют,​ соответственно,​ что Потребитель должен использовать StartTLS и что CA сертификат требуется для идентификации Поставщика. Также обратите внимание на LDIF синтаксис для изменения значений атрибута ('​replace'​).
  
-    The extra options specify, respectively,​ that the consumer must use StartTLS and that the CA certificate is required to verify the Provider'​s identity. Also note the LDIF syntax for changing the values of an attribute ('​replace'​).+Применяем эти изменения:​ 
 +<​code>​sudo ldapmodify -Y EXTERNAL -H ldapi:/// -f consumer_sync_tls.ldif</​code>​
  
-    Implement these changes: +И перестартуем ​slapd: 
- +<​code>​sudo service slapd restart</code>
-    sudo ldapmodify -Y EXTERNAL -H ldapi:/// -f consumer_sync_tls.ldif +
- +
-    And restart ​slapd: +
- +
-    ​sudo service slapd restart +
- +
-    On the Provider, +
- +
-    Check to see that a TLS session has been established. In /var/​log/​syslog,​ providing you have '​conns'​-level logging set up, you should see messages similar to:+
  
 +  ** **На Постащике**:​
 +Проверяем,​ что TLS сессия устанавливается. В /​var/​log/​syslog,​ предполагая что вы настроили уровень журналирования '​conns',​ вы сможете увидеть подобные записи:​
 +<​code>​
     slapd[3620]:​ conn=1047 fd=20 ACCEPT from IP=10.153.107.229:​57922 (IP=0.0.0.0:​389)     slapd[3620]:​ conn=1047 fd=20 ACCEPT from IP=10.153.107.229:​57922 (IP=0.0.0.0:​389)
     slapd[3620]:​ conn=1047 op=0 EXT oid=1.3.6.1.4.1.1466.20037     slapd[3620]:​ conn=1047 op=0 EXT oid=1.3.6.1.4.1.1466.20037
Строка 741: Строка 733:
     slapd[3620]:​ conn=1047 op=1 BIND dn="​cn=admin,​dc=example,​dc=com"​ mech=SIMPLE ssf=0     slapd[3620]:​ conn=1047 op=1 BIND dn="​cn=admin,​dc=example,​dc=com"​ mech=SIMPLE ssf=0
     slapd[3620]:​ conn=1047 op=1 RESULT tag=97 err=0 text     slapd[3620]:​ conn=1047 op=1 RESULT tag=97 err=0 text
 +</​code>​
 ====Установление подлинности через LDAP==== ====Установление подлинности через LDAP====
  
-Once you have a working ​LDAP serveryou will need to install libraries on the client that will know how and when to contact itOn Ubuntu, this has been traditionally accomplishd by installing the libnss-ldap ​packageThis package will bring in other tools that will assist you in the configuration stepInstall this package now:+Поскольку вы имеете работающий ​LDAP сервервам потребуется установить библиотеки на клиенте,​ которые будут знать как и когда к нему (серверу) подсоединятьсяНа Ubuntu ​это традиционно производится установкой пакета **libnss-ldap**Этот пакет добавит другие инструменты,​ которые будут помогать вам на шаге настройкиТеперь установим этот пакет 
 +<​code>​sudo apt-get install libnss-ldap</​code>​
  
-sudo apt-get install libnss-ldap+У вас будут запрошены подробности по вашему LDAP серверу. Если вы сделаете ошибку,​ вы можете попробовать снова используя:​ 
 +<​code>​sudo dpkg-reconfigure ​ldap-auth-config</​code>​
  
-You will be prompted for details of your LDAP serverIf you make a mistake you can try again using:+Результат диалога можно увидеть в /​etc/​ldap.conf. Если ваш сервер требует опции, недоступные в меню, редактируйте этот файл самостоятельно.
  
-sudo dpkg-reconfigure ldap-auth-config+Теперь настраиваем LDAP профиль для NSS: 
 +<​code>​sudo auth-client-config ​-t nss -p lac_ldap</​code>​
  
-The results of the dialog can be seen in /etc/​ldap.conf. If your server requires options not covered in the menu edit this file accordingly.+Настраиваем систему на использование LDAP для аутентификации:​ 
 +<​code>​sudo pam-auth-update<​/code>
  
-Now configure the LDAP profile for NSS:+Из меню, выберите ​LDAP и любые другие механизмы аутентификации,​ которые вам требуются.
  
-sudo auth-client-config -t nss -p lac_ldap+Теперь вы имеете возможность входить в систему,​ используя учетные записи на основе LDAP.
  
-Configure the system to use LDAP for authentication:+Клиентам ​LDAP потребуются ссылки на несколько серверов,​ если используется репликация. В /​etc/​ldap.conf вам надо иметь что-то похожее: 
 +<​code>​uri ldap://​ldap01.example.com ldap://​ldap02.example.com</​code>​
  
-sudo pam-auth-update+Запросы имеют таймаут и будет попытка обратиться к Потребителю (ldap02), если Поставщик (ldap01) станет недоступным.
  
-From the menuchoose ​LDAP and any other authentication mechanisms you need.+Если вы собираетесь использовать LDAP для хранения пользователей SAMBAвам потребуется настроить SAMBA сервер на использование LDAP. Смотрите [[wiki:​руководство_по_ubuntu_server:​авторизация_по_сети:​samba_and_ldap|Samba и LDAP]] для подробностей.
  
-You should now be able to log in using LDAP-based credentials. +<​note>​Альтернативой пакету **libnss-ldap** является пакет **libnss-ldapd**Однако он добавит в систему пакет **nscd**которыйвозможно,​ нежелателенПросто впоследствии удалите его.</​note>​
- +
-LDAP clients will need to refer to multiple servers if replication is in use. In /​etc/​ldap.conf you would have something like: +
- +
-uri ldap://​ldap01.example.com ldap://​ldap02.example.com +
- +
-The request will time out and the Consumer (ldap02) will attempt to be reached if the Provider (ldap01) becomes unresponsive. +
- +
-If you are going to use LDAP to store Samba users you will need to configure the Samba server to authenticate using LDAP. See Samba and LDAP for details. +
- +
-An alternative to the libnss-ldap ​package is the libnss-ldapd ​packageThishoweverwill bring in the nscd package which is problably not wantedSimply remove it afterwards.+
  
 ====Управление пользователями и группами==== ====Управление пользователями и группами====
  
-The ldap-utils ​package comes with enough utilities to manage the directory but the long string of options needed can make them a burden to useThe ldapscripts ​package contains ​wrapper scripts ​to these utilities that some people find easier to use.+Пакет **ldap-utils** поставляется с достаточным количеством утилит для управления каталогами,​ но необходимость использовать длинные строки с опциями делает их применение обременительнымПакет **ldapscripts** содержит оберточные сценарии (wrapper scripts) для этих утилит,​ которые некоторые находят более удобными в использовании.
  
-Install the package+Устанавливаем пакет
- +<​code>​sudo apt-get install ldapscripts</code>
-sudo apt-get install ldapscripts +
- +
-Then edit the file /etc/​ldapscripts/​ldapscripts.conf to arrive at something similar to the following:+
  
 +Затем редактируем файл /​etc/​ldapscripts/​ldapscripts.conf для получения нечто похожего на следующее:​
 +<​code>​
 SERVER=localhost SERVER=localhost
 BINDDN='​cn=admin,​dc=example,​dc=com'​ BINDDN='​cn=admin,​dc=example,​dc=com'​
Строка 796: Строка 782:
 UIDSTART=10000 UIDSTART=10000
 MIDSTART=10000 MIDSTART=10000
 +</​code>​
  
-Now, create the ldapscripts.passwd ​file to allow rootDN ​access to the directory:+Теперь создаем файл ​ldapscripts.passwd ​чтобы разрешить ​rootDN ​доступ к каталогу: 
 +<​code>​sudo sh -c "echo -n '​secret'​ > /​etc/​ldapscripts/​ldapscripts.passwd"​ 
 +sudo chmod 400 /​etc/​ldapscripts/​ldapscripts.passwd</​code>​
  
-sudo sh -c "echo -n 'secret' > /​etc/​ldapscripts/​ldapscripts.passwd" +<​note>​Замените %%"​secret"​%% на действующий пароль для пользователя ​rootDN ​вашей базы.</​note>​
-sudo chmod 400 /​etc/​ldapscripts/​ldapscripts.passwd +
- +
-Replace “secret” with the actual password for your database'​s ​rootDN ​user. +
- +
-The scripts are now ready to help manage your directory. Here are some examples of how to use them: +
- +
-    Create a new user: +
- +
-    sudo ldapadduser george example +
- +
-    This will create a user with uid george and set the user's primary group (gid) to example +
- +
-    Change a user's password: +
- +
-    sudo ldapsetpasswd george +
-    Changing password for user uid=george,​ou=People,​dc=example,​dc=com +
-    New Password:  +
-    New Password (verify):  +
- +
-    Delete a user: +
- +
-    sudo ldapdeleteuser george +
- +
-    Add a group: +
- +
-    sudo ldapaddgroup qa +
- +
-    Delete a group: +
- +
-    sudo ldapdeletegroup qa +
- +
-    Add a user to a group: +
- +
-    sudo ldapaddusertogroup george qa +
- +
-    You should now see a memberUid attribute for the qa group with a value of george. +
- +
-    Remove a user from a group: +
- +
-    sudo ldapdeleteuserfromgroup george qa +
- +
-    The memberUid attribute should now be removed from the qa group. +
- +
-    The ldapmodifyuser script allows you to add, remove, or replace a user's attributes. The script uses the same syntax as the ldapmodify utility. For example:+
  
 +Сценарии теперь готовы помогать в управлении вашим каталогом. Здесь несколько примеров как их использовать:​
 +  ** Создать нового пользователя:​
 +<​code>​sudo ldapadduser george example</​code>​
 +Это создаст пользователя с uid **george** и установит gid **example** в качестве первичной пользовательской группы.
 +  ** Изменить пароль пользователя:​
 +<​code>​sudo ldapsetpasswd george
 +Changing password for user uid=george,​ou=People,​dc=example,​dc=com
 +New Password:
 +New Password (verify):</​code>​
 +  ** Удалить пользователя:​
 +<​code>​sudo ldapdeleteuser george</​code>​
 +  ** Добавить группу:​
 +<​code>​sudo ldapaddgroup qa</​code>​
 +  ** Удалить группу:​
 +<​code>​sudo ldapdeletegroup qa</​code>​
 +  ** Добавить пользователя к группе:​
 +<​code>​sudo ldapaddusertogroup george qa</​code>​
 +Вы теперь можете увидеть атрибут **memberUid** для группы **qa** со значением для **george**.
 +  ** Удалить пользователя из группы:​
 +<​code>​sudo ldapdeleteuserfromgroup george qa</​code>​
 +Атрибут **memberUid** теперь будет удален из группы **qa**.
 +  ** Сценарий **ldapmodifyuser** позволяет вам добавлять,​ удалять или заменять пользовательские атрибуты. Сценарий исползует тот же синтаксис,​ что и утилита **ldapmodify**. Например:​
 +<​code>​
     sudo ldapmodifyuser george     sudo ldapmodifyuser george
     # About to modify the following entry :     # About to modify the following entry :
Строка 864: Строка 832:
     replace: gecos     replace: gecos
     gecos: George Carlin     gecos: George Carlin
 +</​code>​
 +Поле имени пользователя (gecos) теперь %%"​George Carlin"​%%.
 +  ** Приятной особенностью **ldapscripts** является система шаблонов. Шаблоны позволяют вам настраивать атрибуты пользователей,​ групп и компьютерных объектов. Например,​ чтобы разрешить шаблон пользователей,​ отредактируйте /​etc/​ldapscripts/​ldapscripts.conf,​ изменив:​
 +<​code>​UTEMPLATE="/​etc/​ldapscripts/​ldapadduser.template"</​code>​
 +В каталоге /​etc/​ldapscripts находятся шаблоны **sample**. Скопируйте или переименуйте файл ldapadduser.template.sample в /​etc/​ldapscripts/​ldapadduser.template:​
 +<​code>​sudo cp /​usr/​share/​doc/​ldapscripts/​examples/​ldapadduser.template.sample \
 + /​etc/​ldapscripts/​ldapadduser.template</​code>​
  
-    The user's gecos should now be “George Carlin”. +Отредактируйте новый шаблон для добавления желаемых атрибутовСледующее создаст новых пользователей с objectClass inetOrgPerson:​ 
- +<​code>​
-    A nice feature of ldapscripts is the template system. Templates allow you to customize the attributes of user, group, and machine objectes. For example, to enable the user template edit /​etc/​ldapscripts/​ldapscripts.conf changing: +
- +
-    UTEMPLATE="/​etc/​ldapscripts/​ldapadduser.template"​ +
- +
-    There are sample templates in the /​etc/​ldapscripts directory. Copy or rename the ldapadduser.template.sample file to /​etc/​ldapscripts/​ldapadduser.template:​ +
- +
-    sudo cp /​usr/​share/​doc/​ldapscripts/​examples/​ldapadduser.template.sample \ +
-    /​etc/​ldapscripts/​ldapadduser.template +
- +
-    Edit the new template to add the desired attributes. The following will create new users with an objectClass ​of inetOrgPerson:​ +
     dn: uid=<​user>,<​usuffix>,<​suffix>​     dn: uid=<​user>,<​usuffix>,<​suffix>​
     objectClass:​ inetOrgPerson     objectClass:​ inetOrgPerson
Строка 891: Строка 855:
     description:​ User account     description:​ User account
     title: Employee     title: Employee
 +</​code>​
  
-    Notice the <​ask> ​option used for the sn attributeThis will make ldapadduser ​prompt you for it's value.+Отметьте опцию **%%<ask>%%**, использованную для атрибута **sn**Это создает запрос при использовании **ldapadduser** для его значения.
  
-There are utilities in the package that were not covered hereHere is a complete list:+Есть утилиты из пакета,​ которые здесь не рассматривалисьВот их полный список:
  
-ldaprenamemachine +[[http://​manpages.ubuntu.com/​manpages/​en/​man1/​ldaprenamemachine.1.html|ldaprenamemachine]] \\ 
-ldapadduser +[[http://​manpages.ubuntu.com/​manpages/​en/​man1/​ldapadduser.1.html|ldapadduser]] \\ 
-ldapdeleteuserfromgroup +[[http://​manpages.ubuntu.com/​manpages/​en/​man1/​ldapdeleteuserfromgroup.1.html|ldapdeleteuserfromgroup]] \\ 
-ldapfinger +[[http://​manpages.ubuntu.com/​manpages/​en/​man1/​ldapfinger.1.html|ldapfinger]] \\ 
-ldapid +[[http://​manpages.ubuntu.com/​manpages/​en/​man1/​ldapid.1.html|ldapid]] \\ 
-ldapgid +[[http://​manpages.ubuntu.com/​manpages/​en/​man1/​ldapgid.1.html|ldapgid]] \\ 
-ldapmodifyuser +[[http://​manpages.ubuntu.com/​manpages/​en/​man1/​ldapmodifyuser.1.html|ldapmodifyuser]] \\ 
-ldaprenameuser +[[http://​manpages.ubuntu.com/​manpages/​en/​man1/​ldaprenameuser.1.html|ldaprenameuser]] \\ 
-lsldap +[[http://​manpages.ubuntu.com/​manpages/​en/​man1/​lsldap.1.html|lsldap]] \\ 
-ldapaddusertogroup +[[http://​manpages.ubuntu.com/​manpages/​en/​man1/​ldapaddusertogroup.1.html|ldapaddusertogroup]] \\ 
-ldapsetpasswd +[[http://​manpages.ubuntu.com/​manpages/​en/​man1/​ldapsetpasswd.1.html|ldapsetpasswd]] \\ 
-ldapinit +[[http://​manpages.ubuntu.com/​manpages/​en/​man1/​ldapinit.1.html|ldapinit]] \\ 
-ldapaddgroup +[[http://​manpages.ubuntu.com/​manpages/​en/​man1/​ldapaddgroup.1.html|ldapaddgroup]] \\ 
-ldapdeletegroup +[[http://​manpages.ubuntu.com/​manpages/​en/​man1/​ldapdeletegroup.1.html|ldapdeletegroup]] \\ 
-ldapmodifygroup +[[http://​manpages.ubuntu.com/​manpages/​en/​man1/​ldapmodifygroup.1.html|ldapmodifygroup]] \\ 
-ldapdeletemachine +[[http://​manpages.ubuntu.com/​manpages/​en/​man1/​ldapdeletemachine.1.html|ldapdeletemachine]] \\ 
-ldaprenamegroup +[[http://​manpages.ubuntu.com/​manpages/​en/​man1/​ldaprenamegroup.1.html|ldaprenamegroup]] \\ 
-ldapaddmachine +[[http://​manpages.ubuntu.com/​manpages/​en/​man1/​ldapaddmachine.1.html|ldapaddmachine]] \\ 
-ldapmodifymachine +[[http://​manpages.ubuntu.com/​manpages/​en/​man1/​ldapmodifymachine.1.html|ldapmodifymachine]] \\ 
-ldapsetprimarygroup +[[http://​manpages.ubuntu.com/​manpages/​en/​man1/​ldapsetprimarygroup.1.html|ldapsetprimarygroup]] \\ 
-ldapdeleteuser+[[http://​manpages.ubuntu.com/​manpages/​en/​man1/​ldapdeleteuser.1.html|ldapdeleteuser]]
  
 ====Резервное копирование и восстановление==== ====Резервное копирование и восстановление====
  
-Now we have ldap running just the way we wantit is time to ensure we can save all of our work and restore it as needed. +Теперь у нас ​ldap работает именно таккак нам хотелось и настало время убедитьсячто мы можем сохранить всю нашу работу и восстановить ее при необходимости.
- +
-What we need is a way to backup the ldap database(s)specifically the backend (cn=config) and frontend (dc=example,​dc=com)If we are going to backup those databases into, say, /​export/​backup,​ we could use slapcat as shown in the following script, called /​usr/​local/​bin/​ldapbackup:​+
  
 +Что нам требуется,​ это способ сделать резервные копии для базы данных ldap, специфичные для данных баз заднего (cn=config) и переднего плана (dc=example,​dc=com). Если мы собираемся сохранить эти базы, скажем,​ в /​export/​backup,​ мы можем использовать **slapcat** как показано в следующем сценарии с именем /​usr/​local/​bin/​ldapbackup:​
 +<​code>​
 #!/bin/bash #!/bin/bash
  
Строка 933: Строка 898:
 nice ${SLAPCAT} -n 2 > ${BACKUP_PATH}/​access.ldif nice ${SLAPCAT} -n 2 > ${BACKUP_PATH}/​access.ldif
 chmod 640 ${BACKUP_PATH}/​*.ldif chmod 640 ${BACKUP_PATH}/​*.ldif
 +</​code>​
  
-These files are uncompressed text files containing everything in your ldap databases including the tree layoutusernamesand every passwordSo, you might want to consider making ​/​export/​backup ​an encrypted partition and even having the script encrypt those files as it creates themIdeally you should do bothbut that depends on your security requirements.+<​note>​Это несжатые текстовые файлы, содержащие все данные из вашей ​ldap базывключая расположение дереваимена пользователей и каждый парольПоэтому вы можете решить сделать ​/​export/​backup ​шифрованным разделом и даже иметь сценарии шифрования этих файлов сразу после созданияВ идеале вы можете сделать и то и другоено это зависит от ваших требований безопасности.</​note>​
  
-Then, it is just a matter of having a cron script to run this program as often as we feel comfortable with. For manyonce a day sufficesFor others, more often is requiredHere is an example of a cron script called ​/​etc/​cron.d/​ldapbackup ​that is run every night at 22:45h:+Затем имеет смысл создать сценарии ​cron для запуска этой программы настолько частонасколько вам будет комфортноДля большинства достаточно одного раза в день. Для некоторых требуется чащеЗдесь пример сценария ​cron, названного ​/​etc/​cron.d/​ldapbackup, который срабатывает каждую ночь в 22:45: 
 +<​code>​MAILTO=backup-emails@domain.com 
 +45 22 * * *  root    /​usr/​local/​bin/​ldapbackup</​code>​
  
-MAILTO=backup-emails@domain.com +Теперь файлы созданы и они могут быть скопированы на резервный сервер.
-45 22 * * *  root    /​usr/​local/​bin/​ldapbackup +
- +
-Now the files are created, they should be copied to a backup server. +
- +
-Assuming we did a fresh reinstall of ldap, the restore process could be something like this:+
  
 +Предположим мы сделали переустановку ldap; процесс восстановления будет подобен следующему:​
 +<​code>​
 sudo service slapd stop sudo service slapd stop
 sudo mkdir /​var/​lib/​ldap/​accesslog sudo mkdir /​var/​lib/​ldap/​accesslog
Строка 953: Строка 918:
 sudo chown -R openldap:​openldap /​var/​lib/​ldap/​ sudo chown -R openldap:​openldap /​var/​lib/​ldap/​
 sudo service slapd start sudo service slapd start
 +</​code>​
 ====Ссылки==== ====Ссылки====
  
-    The primary resource is the upstream documentation: www.openldap.org +  - Первый ресурс это актуальная документация:​ [[http://www.openldap.org/​|www.openldap.org]]. 
- +  - Существует много страниц руководств пакета ​slapd. ​Здесь наиболее важныеособенно в плане рассматриваемых в этом руководстве материалов
-    There are many man pages that come with the slapd packageHere are some important onesespecially considering the material presented in this guide: +    ​- [[http://​manpages.ubuntu.com/​manpages/​en/​man8/​slapd.8.html|slapd]] 
- +    ​- [[http://​manpages.ubuntu.com/​manpages/​en/​man5/​slapd-config.5.html|slapd-config]] 
-    slapd +    ​- [[http://​manpages.ubuntu.com/​manpages/​en/​man5/​slapd.access.5.html|slapd.access]] 
-    slapd-config +    ​- [[http://​manpages.ubuntu.com/​manpages/​en/​man5/​slapo-syncprov.5.html|slapo-syncprov]] 
-    slapd.access +  - Другие руководства
-    slapo-syncprov +    ​- [[http://​manpages.ubuntu.com/​manpages/​en/​man8/​auth-client-config.8.html|auth-client-config]] 
- +    ​- [[http://​manpages.ubuntu.com/​manpages/​en/​man8/​pam-auth-update.8.html|pam-auth-update]] 
-    Other man pages: +  - [[http://​www.zytrax.com/​books/​ldap/​|LDAP for Rocket Scientists]] от Zytraxруководство менее педантичное,​ но содержащее всесторонне рассмотренный ​LDAP. 
- +  - [[https://​help.ubuntu.com/​community/​OpenLDAPServer|OpenLDAP wiki]] страница сообщества Ubuntu имеет коллекцию заметок. 
-    auth-client-config +  - [[http://​www.oreilly.com/​catalog/​ldapsa/​|LDAP System Administration]] от O'​Reilly ​(текст, ​2003) 
-    pam-auth-update +  - [[http://​www.packtpub.com/​OpenLDAP-Developers-Server-Open-Source-Linux/​book|Mastering OpenLDAP]] от Packt (текст, ​2007)
- +
-    Zytrax'​s ​LDAP for Rocket Scientists; ​a less pedantic but comprehensive treatment of LDAP +
- +
-    A Ubuntu ​community OpenLDAP wiki page has a collection of notes +
- +
-    ​O'​Reilly'​s ​LDAP System Administration (textbook; ​2003) +
- +
-    Packt'​s ​Mastering OpenLDAP (textbook; ​2007)+
  
 ---- ----