3 AUTHOR: Michenaud Laurent <Michenaud Laurent>
5 VERSION : BETA BETA BETA
15 http://www.us.kernel.org/pub/linux/libs/pam/pre/library/Linux-PAM-0.75.tar.bz2
16 http://www.us.kernel.org/pub/linux/libs/pam/pre/library/cracklib-files.tgz
19 1) CrackLib Installation
21 unpack cracklib-files.tgz
23 cp usr/include/* /usr/include/*
24 cp usr/lib/* /usr/lib/*
25 cp usr/sbin/* /usr/sbin/*
30 ./configure --with-mailspool=/var/mail
36 # Create the directory where u can have one file
37 # per service configuration
40 # Creating missing links
42 ln -s libpam.so.0.75 libpam.so.0
43 ln -s libpam_misc.so.0.75 libpam_misc.so.0
46 3) Shadow-20001016 recompilation
48 You have to reinstall the shadow-20001016 package
49 in order to take of PAM.
51 For that, recompile the option --with-pam
53 I am not a pam specialist and maybe it will be good to add
54 a specific configuration for the other services such ftp, telnet,etc...
62 ftp://ftp.OpenLDAP.org/pub/OpenLDAP/openldap-release/openldap-2.0.22.tgz
66 ./configure --prefix=/usr \
68 --localstatedir=/var \
78 --enable-passwd-backend \
86 2) SSL Key Generation for connection encryption
87 -----------------------------------------------
89 mkdir /etc/openldap/ssl
91 openssl req -new -x509 -nodes -out slapd.pem -keyout slapd.key -days 365
94 It will ask a few question needed to generate the key.
96 When asking for Common Name, enter your hostname.
98 I don't know why but without that, it will not work.
101 3) OpenLDAP Configuration
102 --------------------------
104 You should read the documentation.
105 Here is what i use with some explanations.
107 The configuration is /etc/openldap/slapd.conf
109 ###################################
110 # Begin of /etc/openldap/slapd.conf
112 # The following included files define the necessary
114 include /etc/openldap/schema/core.schema
115 include /etc/openldap/schema/cosine.schema
116 include /etc/openldap/schema/inetorgperson.schema
117 include /etc/openldap/schema/nis.schema
123 pidfile /var/run/slapd.pid
124 argsfile /var/run/slapd.args
126 # Load dynamic backend modules:
127 modulepath /usr/libexec/openldap
128 # moduleload back_ldap.la
129 moduleload back_ldbm.la
130 # moduleload back_passwd.la
131 # moduleload back_shell.la
136 # Default acces { none | compare | search | read | write }
139 # Time before an idle connection is killed, -1 to desactivate this fonction
145 # Define the max records number that a research can provide.
148 # Specifie le referral quand slapd ne peut trouver une base
153 # GENERAL BACKEND OPTIONS
154 # options for all databases
157 # Database type : ldbm, shell, passwd
162 # GENERAL DATABASE DIRECTIVES
171 # replica ldap-1.example.com:389 tls=yes
172 # bindmethod=sasl saslmech=GSSAPI
173 # authcId=host/ldap-master.example.com@EXAMPLE.COM
175 # Log file for replication
176 replogfile /var/log/openldap/master-slapd.replog
178 # specifies the DN that is not subject to access control or
179 # administrative limit restrictions for operations on this database. The DN
180 # need not refer to an entry in the directory. The DN may refer to a SASL
182 rootdn "cn=Manager,dc=zerezo,dc=org"
184 # Specify a password for the entry above
186 #rootpw {crypt}fdssdfs
188 # Suffix for this database
189 suffix "dc=zerezo,c=org"
197 # LDBM BACKEND SPECIFIC DIRECTIVES
203 # Cache size for each opened index
206 # Deactivate database lock
209 # Directory that contains lbdm-files
210 directory /var/openldap-ldbm
212 # Defines the index to maintain
213 index objectClass,uid,uidNumber,gidNumber,memberUid eq
214 index cn,mail,surname,givenname eq,subinitial
216 # Droits par default pour les nouveaux index
220 TLSCertificateFile /etc/openldap/ssl/slapd.pem
221 TLSCertificateKeyFile /etc/openldap/ssl/slapd.key
222 TLSCACertificateFile /etc/openldap/ssl/slapd.pem
225 # End of /etc/openldap.slapd.conf
226 #################################
229 Now, we have to configure the log mechanism.
230 U have to add this line in /etc/syslog.conf :
231 local4.* -/var/log/openldap.log
235 3) The starting script /etc/rc.d/init.d/openldap
236 ------------------------------------------------
239 # Begin $rc_base/init.d/
241 # Based on sysklogd script from LFS-3.1 and earlier.
242 # Rewritten by Gerard Beekmans - gerard@linuxfromscratch.org
244 source /etc/sysconfig/rc
249 echo -n "Démarrage du serveur openldap..."
250 /opt/network/libexec/slapd -h "ldap:/// ldaps:///" -d 1
254 echo -n "Arrêt du serveur openldap..."
255 kill -INT `cat /var/run/slapd.pid`
258 echo -n "Rechargement du serveur openldap..."
273 echo "Usage: $0 {start|stop|reload|restart|status}"
277 # End $rc_base/init.d/
283 3) Starting the server
284 ---------------------
286 First, start the openldap server with the script.
287 If it fails, try to launch it by hand with debug mode
288 with the following command :
290 $ /usr/libexec/slapd -d 1
292 Then, execute the following test and checks wether there are no error :
294 ldapsearch -b 'dc=zerezo,dc=org' 'objectclass=*'
298 4) Importing data for OPENLDAP
299 ------------------------------
301 Now, you have to write the file containing your user data.
302 My openldap database has the following structure :
313 Here the file in the LDIF format :
315 # Begin of /tmp/newentry
317 dn: dc=zerezo, dc=org
319 objectclass: organizationalUnit
322 dn:ou=groups, dc=zerezo, dc=org
324 objectclass: organizationalUnit
327 dn:ou=people, dc=zerezo, dc=org
329 objectclass: organizationalUnit
332 dn: cn=Michenaud Laurent, ou=people, dc=zerezo, dc=org
333 cn: Michenaud Laurent
337 objectclass: posixAccount
338 objectclass: shadowAccount
340 userpassword:{crypt}sfsdfdsfd
343 gecos:Michenaud Laurent
345 homeDirectory: /home/zarba
346 shadowLastChange:10877
354 dn: cn=Michenaud Karine, ou=people, dc=zerezo, dc=org
359 objectclass: posixAccount
360 objectclass: shadowAccount
362 userpassword:{crypt}sfsdfdsfd
365 gecos:Michenaud Karine
367 homeDirectory: /home/karine
368 shadowLastChange:10877
377 dn: cn=wheel, ou=groups, dc=zerezo, dc=org
379 objectclass: posixGroup
384 dn: cn=users, ou=groups, dc=zerezo, dc=org
386 objectclass: posixGroup
392 # End of file /tmp/newentry
394 Import the file in your database with the following command :
396 $ ldapadd -f /tmp/newentry -D "cn=Manager,dc=zerezo,dc=org" -w secret
399 Then, you can execute the following test for fun :
401 ldapsearch -b 'dc=zerezo,dc=org' 'cn=Michenaud Laurent'
402 ldapsearch -u -b 'dc=zerezo,dc=org' 'cn=Michenaud Laurent' sn mail
404 See in the LDAP Howto at www.linuxdoc.org to modify or
405 delete some ldap records.
412 Download here : ftp://ftp.padl.com/pub/pam_ldap.tgz
416 Strange installation but i didnot find any other way
417 to make compilation working.
419 ./configure --with-ldap-lib=openldap --with-ldap-dir=/usr
424 sed 's|depcomp = $(SHELL) $(top_srcdir)/depcomp||' \
425 Makefile > Makefile.tmp &&
426 mv Makefile.tmp Makefile
431 # We copy all the pam service config files in /etc/pam.d/
432 cp pam.d/* /etc/pam.d/
440 download here : ftp://ftp.padl.com/pub/nss_ldap.tgz
444 ./configure --enable-schema-mapping --with-ldap-lib=openldap --with-ldap-dir=/usr
449 sed 's|depcomp = $(SHELL) $(top_srcdir)/depcomp||' \
450 Makefile > Makefile.tmp &&
451 mv Makefile.tmp Makefile
458 You have to edit the /etc/nsswitch.conf like this :
464 3) LDAP client configuration file
466 # Begin of /etc/ldap.conf
468 # Your LDAP server. Must be resolvable without using LDAP.
471 # The distinguished name of the search base.
472 base dc=zerezo,dc=org
477 # The distinguished name to bind to the server with.
478 # Optional: default is to bind anonymously.
479 #binddn cn=proxyuser,dc=padl,dc=com
481 # The credentials to bind with.
482 # Optional: default is no credential.
485 # The distinguished name to bind to the server with
486 # if the effective user ID is root. Password is
487 # stored in /etc/ldap.secret (mode 600)
488 #rootbinddn cn=manager,dc=padl,dc=com
491 # Optional: default is 389.
505 # Idle timelimit; client will close connections
506 # (nss_ldap only) if the server has not been contacted
507 # for the number of seconds specified below.
510 # Filter to AND with uid=%s
511 pam_filter objectclass=posixAccount
513 # The user ID attribute (defaults to uid)
514 pam_login_attribute uid
516 # Search the root DSE for the password policy (works
517 # with Netscape Directory Server)
518 #pam_lookup_policy yes
520 # Check the 'host' attribute for access control
521 # Default is no; if set to yes, and user has no
522 # value for the host attribute, and pam_ldap is
523 # configured for account management (authorization)
524 # then the user will not be allowed to login.
525 #pam_check_host_attr yes
527 # Group to enforce membership of
528 #pam_groupdn cn=PAM,ou=Groups,dc=padl,dc=com
530 # Group member attribute
531 #pam_member_attribute uniquemember
532 pam_member_attribute memberuid
534 # Specify a minium or maximum UID number allowed
538 # Template login attribute, default template user
539 # (can be overriden by value of former attribute
541 #pam_login_attribute userPrincipalName
542 #pam_template_login_attribute uid
543 #pam_template_login nobody
545 # HEADS UP: the pam_crypt, pam_nds_passwd,
546 # and pam_ad_passwd options are no
549 # Do not hash the password at all; presume
550 # the directory server will do it, if
551 # necessary. This is the default.
554 # Hash password locally; required for University of
555 # Michigan LDAP server, and works with Netscape
556 # Directory Server if you're using the UNIX-Crypt
557 # hash mechanism and not using the NT Synchronization
562 # Remove old password first, then update in
563 # cleartext. Necessary for use with Novell
564 # Directory Services (NDS)
567 # Update Active Directory password, by
568 # creating Unicode password and updating
569 # unicodePwd attribute.
572 # Use the OpenLDAP password change
573 # extended operation to update the password.
576 # RFC2307bis naming contexts
578 # nss_base_XXX base?scope?filter
579 # where scope is {base,one,sub}
580 # and filter is a filter to be &'d with the
582 # You can omit the suffix eg:
584 # nss_base_passwd ou=People,
585 # to append the default base DN but this
586 # may incur a small performance impact.
587 #nss_base_passwd ou=People,dc=padl,dc=com?one
588 #nss_base_shadow ou=People,dc=padl,dc=com?one
589 #nss_base_group ou=Group,dc=padl,dc=com?one
590 #nss_base_hosts ou=Hosts,dc=padl,dc=com?one
591 #nss_base_services ou=Services,dc=padl,dc=com?one
592 #nss_base_networks ou=Networks,dc=padl,dc=com?one
593 #nss_base_protocols ou=Protocols,dc=padl,dc=com?one
594 #nss_base_rpc ou=Rpc,dc=padl,dc=com?one
595 #nss_base_ethers ou=Ethers,dc=padl,dc=com?one
596 #nss_base_netmasks ou=Networks,dc=padl,dc=com?ne
597 #nss_base_bootparams ou=Ethers,dc=padl,dc=com?one
598 #nss_base_aliases ou=Aliases,dc=padl,dc=com?one
599 #nss_base_netgroup ou=Netgroup,dc=padl,dc=com?one
601 # attribute/objectclass mapping
603 #nss_map_attribute rfc2307attribute mapped_attribute
604 #nss_map_objectclass rfc2307objectclass mapped_objectclass
606 # configure --enable-nds is no longer supported.
608 #nss_map_attribute uniqueMember member
610 # configure --enable-mssfu-schema is no longer supported.
612 #nss_map_objectclass posixAccount User
613 #nss_map_attribute uid msSFUName
614 #nss_map_attribute uniqueMember posixMember
615 #nss_map_attribute userPassword msSFUPassword
616 #nss_map_attribute homeDirectory msSFUHomeDirectory
617 #nss_map_objectclass posixGroup Group
618 #pam_login_attribute msSFUName
619 #pam_filter objectclass=User
622 # configure --enable-authpassword is no longer supported
623 # For authPassword support, now do:
624 #nss_map_attribute userPassword authPassword
627 # For IBM SecureWay support, do:
628 #nss_map_objectclass posixAccount aixAccount
629 #nss_map_attribute uid userName
631 #nss_map_attribute gidNumber gid
632 #nss_map_attribute uidNumber uid
633 #nss_map_attribute userPassword passwordChar
634 #nss_map_objectclass posixGroup aixAccessGroup
635 #nss_map_attribute cn groupName
636 #nss_map_attribute uniqueMember member
637 #pam_login_attribute userName
638 #pam_filter objectclass=aixAccount
644 # Netscape SDK SSL options
645 #sslpath /etc/ssl/certs/cert7.db
647 # OpenLDAP SSL mechanism
648 # start_tls mechanism uses the normal LDAP port, LDAPS typically 636
652 # OpenLDAP SSL options
653 # Require and verify server certificate (yes/no)
658 # CA certificates for server certificate verification
659 # At least one of these are required if tls_checkpeer is "yes"
660 #tls_cacertfile /etc/ssl/ca.cert
661 #tls_cacertdir /etc/ssl/certs
664 # See man ciphers for syntax
667 # Client certificate and key
668 # Use these, if your server requires client authentication.
673 4) Check the permission
675 -rw-r--r-- root.root /etc/ldap.conf
676 -rw------- root.root /etc/openldap/slapd.conf
679 5) Examples of extension of nss_ldap
681 You can put your services definition in your openldap too.
682 Here is an example ldif file for services :
684 dn:ou=tcpIp, dc=zerezo, dc=org
686 objectclass: organizationalUnit
689 dn: cn=swat,ou=tcpIp,dc=zerezo,dc=org
691 objectclass: ipService
693 ipServiceProtocol: tcp
696 dn: cn=cups,ou=tcpIp,dc=zerezo,dc=org
698 objectclass: ipService
700 ipServiceProtocol: tcp
703 Then just add "ldap" in nsswitch.conf for the line services.
705 What is bad is that aliases are not managed in the schema.
707 You can define too your networks, protocols and rpc in the
711 ==========================
712 V - PROFTPD auth with LDAP
713 ==========================
715 It just speaks about adding LDAP to proftpd...
716 It doesnot speak about installing and configuring proftpd...
718 download here : http://horde.net/~jwm/software/mod_ldap/mod_ldap-2.8.1.tar.bz2
722 Proftpd-1.2.4 provides only mod_ldap-2.7.6 so you have to download the
723 latest version of the module.
725 Extract the module archive and copy mod_ldap.c in your proftpd-1.2.4/contrib/
727 Proftpd can work with LDAP SSL/TLS. To enable SSL/TLS, edit mod_ldap.c
728 and uncomment /* #define USE_LDAPV3_TLS */
730 Recompile proftpd with the option : --with-modules=mod_ldap
735 In your proftpd.conf, just add :
738 LDAPDNInfo cn=Manager,dc=zerezo,dc=org password
739 LDAPDoAuth on "dc=zerezo,dc=org"
742 I had to add these parameters for the global section and for
743 each virtual host to make it work
745 You have to create the /etc/ftpusers, /etc/shells too
748 ============================
749 VII - POSTFIX Auth with LDAP
750 ============================
752 Postfix doesnot work with LDAP-TLS/SSL.
756 Unpack the postfix tarballs and execute the following commands,
757 and then compile like you are used to to it.
760 make makefiles CCARGS="-I/usr/local/include -DHAS_LDAP" \
761 AUXLIBS="-L/usr/local/lib -lldap -L/usr/local/lib -llber"
764 2) Configuration in your main.cf files.
766 Here is a basic configuration for integrating ldap in postfix.
767 I know you can do more like integrating your files /etc/aliases,
768 sender_canonical and recipient_canonicial in the openldap database.
770 alias_maps = hash:/etc/aliases, ldap:ldapsource
772 ldapsource_server_host = localhost
773 ldapsource_server_port = 389
774 ldapsource_search_base = dc=zerezo, dc=org
775 ldapsource_timeout = 5
776 #ldapsource_query_filter=mailacceptinggeneralid=%s
777 #ldapsource_domain = postfix.org, hash:/etc/postfix/searchdomains
778 #ldapsource_result_attribute = mailbox,maildrop
779 #ldapsource_special_result_attribute = member
780 #ldapsource_bind = no
781 #ldapsource_bind_dn = uid=postfix, dc=your, dc=com
782 #ldapsource_bind_pw = postfixpw
789 1) GQ, an interface to browse/edit an ldap database
791 download here : http://biot.com/gq/download/gq-0.4.0.tar.gz
797 2) Directory Administrator
799 A great program to manager users and group
803 http://prdownloads.sourceforge.net/directoryadmin/directory_administrator-1.1.3.tar.gz
814 1) Samba installation
816 I recommend Samba 2.2.2_HEAD
819 ./configure --prefix=/opt/network \
821 --with-configdir=/etc/samba \
822 --with-privatedir=/etc/samba/private \
829 --with-ssl-lib=/opt/network/lib \
830 --with-ssl-include=/opt/network/include \
837 cp examples/LDAP/samba.schema /etc/openldap/schema/
842 Add in /etc/openldap/slapd.conf :
843 include /etc/openldap/schema/samba.schema
845 access to attrs=lmPassword,ntPassword
846 by 'cn=samba,ou=SystemAccounts,dc=zerezo,dc=Org'
847 write by self write by * auth
850 Edit samba.schema and delete the displayName attribute
851 because we have already it.
853 Then we need to precise the password for accessing the LDAP server
862 I wrote this hint while discovering openldap.
863 There may be some errors and it may be incomplete.
865 Feel free to modify this hint to improve it :)
868 - Adding security rules
869 - exporting an entire LDAP ( backup )
870 - Samba Auth with LDAP ( Completing )
871 - Postfix more integration