wiki:LDAP_Configuration

LDAP Configuration

The following script demonstrates retrieving the LDIF export report from the web interface and updating a local LDAP directory. Typically this script would be run periodically to keep the LDAP directory updated with the latest available data. This option allows for integration with various third party systems.

#!/bin/bash

#Request the login page
wget --save-cookies cookies.txt --keep-session-cookies http://192.168.0.1:8080
rm index.html
#Submit the login credentials
wget --load-cookies cookies.txt --keep-session-cookies --post-data="j_username=absuser&j_password=shareme" http://192.168.0.1:8080/j_security_check
rm index.html
#Request the LDIF file
wget --load-cookies cookies.txt --keep-session-cookies --post-data="contextName=dc=contacts,dc=addressbook,dc=com" http://192.168.0.1:8080/reports/contacts.ldif
rm cookies.txt

#Delete the previous contacts from LDAP
ldapdelete -D "cn=ldapadmin,dc=addressbook,dc=com" -w "password" -x -r dc=contacts,dc=addressbook,dc=com
#Create the base context
ldapadd -D "cn=ldapadmin,dc=addressbook,dc=com" -w "password" -x -c -f InitialImport.ldif 
#Import the new contacts
ldapadd -D "cn=ldapadmin,dc=addressbook,dc=com" -w "password" -x -c -f contacts.ldif 
rm contacts.ldif