[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
Re: How to query data DIRECTLY from MySql backend
> Hi there,
> I have successfully installed openldap-2.2.14 on SuSe
> SLES 8.1 Linux to work with mysql-3.23.52-27. The
> MySql alone is working very well.
> And I have follow instruction to install the test
> scripts obtained from directory
> ~openldap-2.2.14/servers/slapd/back-sql/
> rdbms_depend/mysql i.e.
> backsql_create.sql
> testdb_create.sql
> testdb_data.sql
> testdb_metadata.sql
> I can use ldapsearch from another Linux box to obtain
> response from test with the comand
> # ldapsearch -x -h <ldapserver> -b "o=sql,c=RU"
>
> Now I want to use ldap to retrieve data from another
> Mysql database called squid_users consists of only 1
> table called userdata consists of hundreds of
> user records such as loginname, firstname, lastname,
> middlename and password.
> My question is I have no idea how to use ldapsearch
> (or Window ldapbrowser GUI)to retrieve all or may be
> just query one user data DIRECTLY from squid_users.
>
> I have the following ldap tables created in Mysql
> database squid_users;
> ldap_attr_mappings, ldap_oc_mappings, ldap_entries
>
> but the ldap_entries is blank because I don't want to
> duplicate all Mysql data into the ldap_entries table.
>
> Much appreciate if someone can provide some direction.
I'm not familiar enough with mysql to provide precise
directions, but with other RDBMSes I've been able to use
a view to mimic the behavior of the ldap_entries table.
You need to compile back-sql with the switch to enable
string keys, since your table doesn't appear to have a
numeric key. This means a loss in performances, of course,
so you might prefer to add a numeric key to your table.
Then you need to do something like, assuming objectClass 1
is "organization" and objectClass 2 is "inetOrgPerson":
CREATE VIEW dbo.ldap_entries
> AS
> SELECT ACCOUNTNO AS id,
> 'uid="' + ACCOUNTNO + '",ou=People,dc=neotool,dc=com' AS dn,
> 1 AS oc_map_id,
> 'suffixEntry' AS parent,
> ACCOUNTNO AS keyval
> FROM dbo.CONTACT1
create view ldap_enties as
select
loginname as "id",
concat("uid=",loginname,",dc=example,dc=com") as "dn",
2 as "oc_map_id",
"baseObject" as "parent,
loginname as "keyval"
from table squid_users union select
"baseObject" as "id",
"dc=example,dc=com" as "dn",
1 as "oc_map_id",
"baseObject" as "parent",
"baseObject" as "keyval"
from table ldap_oc_mappings where ldap_oc_mappings.id=1;
replace "dc=example,dc=com" with your naming context; this should allow a
flat database with "dc=example,dc=com" as base object of class
"organization" and one-level users of class "inetOrgPerson".
Note I've written the above without testing it, based on previous
experience with different RDBMSes, so there might need some work to get it
running with MySQL.
p.
--
Pierangelo Masarati
mailto:pierangelo.masarati@sys-net.it
SysNet - via Dossi,8 27100 Pavia Tel: +390382573859 Fax: +390382476497