lunes, 30 de enero de 2012

OpenLdap ldap proxy

Another usefull feature of openLDAP is ldap backend.With it you can use a ldap server as a backend for queries. This backend is very similar to the "meta" backend, but you must use the same DN in both origin and target servers.

In example

############  LDAP opensso users ##################################
database ldap
suffix          "ou=persons,dc=test,dc=es"
uri             ldap://localhost:1389/
Will be shown in the proxy ldap as base DN: ou=persons,dc=test,dc=es

If you want to map the base DN with diferent names then meta-backend is your friend

Openldap script backend

Openldap allows you to customize the backend in several ways. The most usefull in order to prepare a prototype is shellbackend.
With this backend you can create a custom shellscript or executable and use it to return a ldap response.


References

Introduction to the slapd backend

Reference guide for slapd configuration

Configuration

############  LDAP SCRIPT  ##################################
database shell
suffix          "o=shell,dc=sia,dc=es"
search          /opt/soft/openldap/libexec/searchSamle.sh
#######################################################################

code

#! /bin/bash
output() {
printf '%s\n' "$*"

}
echo $?>"/opt/soft/openldap/var/log/log.data"
while true
do
read data
if [ $? -eq 0 ]
then
echo $data>>"/opt/soft/openldap/var/log/log.data"
else
break
fi
done
output "dn: cn=Boris Norris,o=shell,dc=sia,dc=es"
output "cn: Boris Norris"
output ""
output "RESULT"
output "code: 0"
exit 0