[Date Prev][Date Next] [Chronological] [Thread] [Top]

Patch against 2.3.24 // wishlist



Dear list,

I'm not such a programmer or anything, but here is what I found out
and I like to take part in discussing the topic for making the patch
to join the openldap software.


I was playing with back-sql, in detail with mysql when noticing that searching over two views or more get's *VERY* slow. So I was looking for an replacement of the setup that can be found in man back-sql.

I finally came to the result of using just *one* view in my mysql-database.

That gave me a strange error that looks like the follwing
error message of the sql-server log:

SELECT DISTINCT ldap_entries.id,ldap_entries.id,'inetOrgPerson' AS
objectClass,ldap_entries.dn AS dn FROM ldap_entries,ldap_entries WHERE
ldap_entries.id=ldap_entries.keyval AND ldap_entries.oc_map_id=1 AND 9=9 AND
3=3;


and the errormessage was: ERROR 1066 (42000): Not unique table/alias: 'ldap_entries'
as "FROM ldap_entries,ldap_entries" is not working here.




So I patched servers/slapd/back-sql/search.c and now everything is working
and working at a useable speed for our MUA's that use this slapd.


Here is an example result of ldapsearch:

# 9, foo.bar
dn: uid=9,dc=foo,dc=bar
objectClass: inetOrgPerson
cn: Simon Anderseck
sn: Anderseck
mail: s.anderseck@foo.bar
givenName: Simon

# 22, foo.bar
dn: uid=22,dc=foo,dc=bar
objectClass: inetOrgPerson
cn: Thomas Reifferscheid
sn: Reifferscheid
mail: t.reifferscheid@foo.bar
givenName: Thomas

# 32, foo.bar
dn: uid=32,dc=foo,dc=bar
objectClass: inetOrgPerson
cn: Thomas Reifferscheid
sn: Reifferscheid
mail: reiffert@foobar.de
givenName: Thomas



and the appropriate mysql-statement looks like:

mysql> select * from ldap_entries where id=22 or id=32 or id=9;
+----+--------------------------+-----------+---------------+-----------------
-----+----------------------------------+-----------+--------+--------+
| id | dn                       | givenName | sn            | cn
     | mail                             | oc_map_id | parent | keyval |
+----+--------------------------+-----------+---------------+-----------------
-----+----------------------------------+-----------+--------+--------+
|  9 | uid=9,dc=diefirma,dc=de  | Simon     | Anderseck     | Simon Anderseck
     | s.anderseck@foo.bar              |         1 |      1 |      9 |

| 22 | uid=22,dc=diefirma,dc=de | Thomas    | Reifferscheid | Thomas Reiffersc
heid | t.reifferscheid@foo.bar          |         1 |      1 |     22 |

| 32 | uid=32,dc=diefirma,dc=de | Thomas    | Reifferscheid | Thomas Reiffersc
heid | reiffert@foobar.de               |         1 |      1 |     32 |

+----+--------------------------+-----------+---------------+-----------------
-----+----------------------------------+-----------+--------+--------+


I know my patch is not working for all cases but my own case, so it definitly needs some attention from someone who is more into this.




Here is the output of other tables used:

mysql> select * from ldap_attr_mappings;
+----+-----------+-----------+------------------------+------------+--------------+------------+----------+-------------+-------------+---------------+
| id | oc_map_id | name | sel_expr | sel_expr_u | from_tbls | join_where | add_proc | delete_proc | param_order | expect_return |
+----+-----------+-----------+------------------------+------------+--------------+------------+----------+-------------+-------------+---------------+
| 1 | 1 | cn | ldap_entries.cn | NULL | ldap_entries | 1=1 | NULL | NULL | 3 | 0 |
| 2 | 1 | mail | ldap_entries.mail | NULL | ldap_entries | 1=1 | NULL | NULL | 3 | 0 |
| 3 | 1 | givenName | ldap_entries.givenName | NULL | ldap_entries | 1=1 | NULL | NULL | 3 | 0 |
| 4 | 1 | sn | ldap_entries.sn | NULL | ldap_entries | 1=1 | NULL | NULL | 3 | 0 |
+----+-----------+-----------+------------------------+------------+--------------+------------+----------+-------------+-------------+---------------+
4 rows in set (0.00 sec)



mysql> select * from ldap_entry_objclasses; +----------+----------+ | entry_id | oc_name | +----------+----------+ | 1 | dcObject | +----------+----------+ 1 row in set (0.00 sec)

mysql> select * from ldap_oc_mappings;
+----+---------------+--------------+--------+-------------+-------------+---------------+
| id | name | keytbl | keycol | create_proc | delete_proc | expect_return |
+----+---------------+--------------+--------+-------------+-------------+---------------+
| 1 | inetOrgPerson | ldap_entries | id | NULL | NULL | 0 |
+----+---------------+--------------+--------+-------------+-------------+---------------+
1 row in set (0.00 sec)




and finally the slapd.conf

backend sql
database sql
suffix          "dc=foo,dc=bar"
rootdn          "cn=admin,dc=foo,dc=bar"
rootpw          V3ryStr0ngP4ssw0rd
dbname          myodbc
dbuser          ldap
dbpasswd        andanotherpasswordlongenoughtokeephackersfromgaining
has_ldapinfo_dn_ru      yes
baseObject /usr/local/ldap/etc/openldap/baseobject

and

cat /usr/local/ldap/etc/openldap/baseobject
dn: dc=foo,dc=bar
objectClass: inetOrgPerson
objectClass: dcObject





The patch is attached to the mail.


Please dont hit me that hard about all the nonsense-stuff in my setup, please try to keep the eye on how the patch can be done better and finally make it into openldap


Kind regards Thomas Reifferscheid
--- openldap-2.3.24.old/servers/slapd/back-sql/search.c	2006-01-03 23:16:24.000000000 +0100
+++ openldap-2.3.24/servers/slapd/back-sql/search.c	2006-06-30 14:57:50.000000000 +0200
@@ -1379,8 +1379,8 @@
 	backsql_strfcat_x( &bsi->bsi_from,
 			bsi->bsi_op->o_tmpmemctx,
 			"lb",
-			(ber_len_t)STRLENOF( " FROM ldap_entries," ),
-				" FROM ldap_entries,",
+			(ber_len_t)STRLENOF( " FROM " ),
+				" FROM ",
 			&bsi->bsi_oc->bom_keytbl );
 
 	backsql_strfcat_x( &bsi->bsi_join_where,