13.07.2015 Views

Linux System Administration Recipes A Problem-Solution Approach

Linux System Administration Recipes A Problem-Solution Approach

Linux System Administration Recipes A Problem-Solution Approach

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 2 ■ CENTRALIZING YOUR NETWORK: KERBEROS, LDAP, AND NFSIf slapd won’t start and there’s an “unstable alock” message in the logs (increase logging in/etc/ldap/slapd.conf to 1 to get better error messages), move /var/lib/ldap/alock out of the way andrestart. (/var/lib/ldap is where the various database files live. You shouldn’t need to interact with thisvery often.) Note that you may need to restart a couple of times and/or allow time for the restart to checkthe database, because the problem that this message indicates is that the database is or might becorrupt.2-7. Using LDAPThe basic LDAP commands are ldapadd, ldapmodify, and ldapdelete. Run kinit ldapadm before any ofthese to authenticate yourself if you’re using LDAP with Kerberos (replace ldapadm with your LDAPadmin user if it’s different). If using non-Kerberos authentication, use the -D and -W options:ldapadd -D cn=ldapadm,ou=admin,dc=example,dc=com -W-D specifies the distinguished name (DN) to use to bind to the server. This should be the DN of yourlocal admin or another user with appropriate privileges.-W will prompt you for the password, which is more secure than using the -w password option on thecommand line. The same options are valid for the other LDAP commands.■ Note See recipe 2-11 for how to use LDAP with Perl in a script.ldapsearchTo find a specific entry, use ldapsearch:ldapsearch "(uid=jkemp)"This uses a search filter in an LDAP-specific format. This example would search for an entry with theuid value exactly equal to jkemp. To search for a value that ends with kemp, you could use the following:ldapsearch "(uid=*kemp)"It’s important to get the double quotes and the brackets in the correct order! (The quotes go on theoutside.) You can also use AND and OR arguments, and other mathematical operators are supported. Thefollowing would search for a user who had a group ID greater than or equal to 1005 and a tcsh shell:ldapsearch "(&(gidNumber>=1005)(loginShell=*tcsh))"The AND is given by the & at the start of the filter (note the use of brackets). To exclude a particularuser from this, you can use !. The following would return all users with a group ID >= 1005 and a tcshshell, except for the user jkemp:ldapsearch "(&(gidNumber>=1005)(loginShell=*tcsh)(!uid=jkemp))"40Download at WoweBook.Com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!