LDAP Foreign Data Wrapper¶
Purpose¶
This fdw can be used to access directory servers via the LDAP protocol. Tested with OpenLDAP. It supports: simple bind, multiple scopes (subtree, base, etc)
Dependencies¶
If using Multicorn >= 1.1.0, you will need the ldap3 library:
For prior version, you will need the ldap library:
Required options¶
uri (string) The URI for the server, for example “ldap://localhost”.
path (string) The base in which the search is performed, for example “dc=example,dc=com”.
objectclass (string) The objectClass for which is searched, for example “inetOrgPerson”.
scope (string) The scope: one, sub or base.
Optional options¶
binddn (string) The binddn for example ‘cn=admin,dc=example,dc=com’.
bindpwd (string) The credentials for the binddn.
Usage Example¶
To search for a person definition:
CREATE SERVER ldap_srv foreign data wrapper multicorn options (
wrapper 'multicorn.ldapfdw.LdapFdw'
);
CREATE FOREIGN TABLE ldapexample (
mail character varying,
cn character varying,
description character varying
) server ldap_srv options (
uri 'ldap://localhost',
path 'dc=lab,dc=example,dc=com',
scope 'sub',
binddn 'cn=Admin,dc=example,dc=com',
bindpwd 'admin',
objectClass '*'
);
select * from ldapexample;
mail | cn | description
-----------------------+----------------+--------------------
test@example.com | test |
admin@example.com | admin | LDAP administrator
someuser@example.com | Some Test User |
(3 rows)