From d252d9c53525bd830a4073717697ad15e08ac3f7 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Tue, 18 Jan 2005 23:21:48 +0000 Subject: [PATCH] map referrals in regular metadata structure (need to remove some of the specific code) --- .../rdbms_depend/pgsql/testdb_create.sql | 7 ++ .../rdbms_depend/pgsql/testdb_data.sql | 1 + .../rdbms_depend/pgsql/testdb_metadata.sql | 19 ++++- tests/data/slapd-sql.conf | 4 - tests/data/sql-read.out | 84 ++++++++++++++++--- tests/data/sql-write.out | 54 +++++++++--- tests/scripts/sql-test900-write | 42 +++++++--- 7 files changed, 173 insertions(+), 38 deletions(-) diff --git a/servers/slapd/back-sql/rdbms_depend/pgsql/testdb_create.sql b/servers/slapd/back-sql/rdbms_depend/pgsql/testdb_create.sql index f156891dff..30a7378fe4 100644 --- a/servers/slapd/back-sql/rdbms_depend/pgsql/testdb_create.sql +++ b/servers/slapd/back-sql/rdbms_depend/pgsql/testdb_create.sql @@ -37,3 +37,10 @@ create table phones ( pers_id int not null ); +drop table referrals; +drop sequence referrals_id_seq; +create table referrals ( + id serial not null primary key, + name varchar(255) not null +); + diff --git a/servers/slapd/back-sql/rdbms_depend/pgsql/testdb_data.sql b/servers/slapd/back-sql/rdbms_depend/pgsql/testdb_data.sql index f7743f6231..2084a18795 100644 --- a/servers/slapd/back-sql/rdbms_depend/pgsql/testdb_data.sql +++ b/servers/slapd/back-sql/rdbms_depend/pgsql/testdb_data.sql @@ -15,3 +15,4 @@ insert into authors_docs (pers_id,doc_id) values (1,1); insert into authors_docs (pers_id,doc_id) values (1,2); insert into authors_docs (pers_id,doc_id) values (2,1); +insert into referrals (id,name) values (1,'Referral'); diff --git a/servers/slapd/back-sql/rdbms_depend/pgsql/testdb_metadata.sql b/servers/slapd/back-sql/rdbms_depend/pgsql/testdb_metadata.sql index e841eb9d09..11ec801c8a 100644 --- a/servers/slapd/back-sql/rdbms_depend/pgsql/testdb_metadata.sql +++ b/servers/slapd/back-sql/rdbms_depend/pgsql/testdb_metadata.sql @@ -14,6 +14,8 @@ insert into ldap_oc_mappings (id,name,keytbl,keycol,create_proc,delete_proc,expe insert into ldap_oc_mappings (id,name,keytbl,keycol,create_proc,delete_proc,expect_return) values (3,'organization','institutes','id','SELECT create_o()','DELETE FROM institutes WHERE id=?',0); +insert into ldap_oc_mappings (id,name,keytbl,keycol,create_proc,delete_proc,expect_return) values (4,'referral','referrals','id','SELECT create_referral()','DELETE FROM referrals WHERE id=?',0); + -- attributeType mappings: describe how an attributeType for a certain objectClass maps to the SQL data. -- id a unique number identifying the attribute -- oc_map_id the value of "ldap_oc_mappings.id" that identifies the objectClass this attributeType is defined for @@ -49,6 +51,8 @@ insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where, insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return) values (12,3,'dc','lower(institutes.name)','institutes,ldap_entries AS dcObject,ldap_entry_objclasses AS auxObjectClass','institutes.id=dcObject.keyval AND dcObject.oc_map_id=3 AND dcObject.id=auxObjectClass.entry_id AND auxObjectClass.oc_name=''dcObject''',NULL,NULL,3,0); +insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return) values (13,4,'ou','referrals.name','referrals',NULL,'UPDATE referrals SET name=? WHERE id=?',NULL,3,0); + -- entries mapping: each entry must appear in this table, with a unique DN rooted at the database naming context -- id a unique number > 0 identifying the entry @@ -68,18 +72,21 @@ insert into ldap_entries (id,dn,oc_map_id,parent,keyval) values (5,'documentTitl insert into ldap_entries (id,dn,oc_map_id,parent,keyval) values (6,'documentTitle=book2,dc=example,dc=com',2,1,2); +insert into ldap_entries (id,dn,oc_map_id,parent,keyval) values (7,'ou=Referral,dc=example,dc=com',4,1,1); + -- objectClass mapping: entries that have multiple objectClass instances are listed here with the objectClass name (view them as auxiliary objectClass) -- entry_id the "ldap_entries.id" of the entry this objectClass value must be added -- oc_name the name of the objectClass; it MUST match the name of an objectClass that is loaded in slapd's schema insert into ldap_entry_objclasses (entry_id,oc_name) values (1,'dcObject'); -insert into ldap_entry_objclasses (entry_id,oc_name) values (4,'referral'); +insert into ldap_entry_objclasses (entry_id,oc_name) values (7,'extensibleObject'); + -- referrals mapping: entries that should be treated as referrals are stored here -- entry_id the "ldap_entries.id" of the entry that should be treated as a referral -- url the URI of the referral -insert into ldap_referrals (entry_id,url) values (4,'ldap://localhost:9010/'); +insert into ldap_referrals (entry_id,url) values (7,'ldap://localhost:9010/'); -- procedures -- these procedures are specific for this RDBMS and are used in mapping objectClass and attributeType creation/modify/deletion @@ -131,3 +138,11 @@ as ' select max(id) from institutes ' language 'sql'; +create function create_referral () returns int +as ' + select setval (''referrals_id_seq'', (select case when max(id) is null then 1 else max(id) end from referrals)); + insert into referrals (id,name,surname) + values ((select case when max(id) is null then 1 else nextval(''referrals_id_seq'') end from referrals),'''',''''); + select max(id) from referrals +' language 'sql'; + diff --git a/tests/data/slapd-sql.conf b/tests/data/slapd-sql.conf index a7b4bfa6fe..3d3adacb6e 100644 --- a/tests/data/slapd-sql.conf +++ b/tests/data/slapd-sql.conf @@ -39,10 +39,6 @@ access to attr=userpassword access to * by * read -# FIXME: this is required to work with referrals the old way; -# the new way requires to map referrals in ldap_oc_mappings on their own -schemacheck off - ####################################################################### # sql database definitions ####################################################################### diff --git a/tests/data/sql-read.out b/tests/data/sql-read.out index 33a5f24b65..1dd9386354 100644 --- a/tests/data/sql-read.out +++ b/tests/data/sql-read.out @@ -21,6 +21,8 @@ documentTitle: book2 documentAuthor: cn=Mitya Kovalev,dc=example,dc=com documentIdentifier: document 2 +# refldap://localhost:9010/dc=example,dc=com??one + dn: cn=Mitya Kovalev,dc=example,dc=com objectClass: inetOrgPerson cn: Mitya Kovalev @@ -39,7 +41,11 @@ seeAlso: documentTitle=book1,dc=example,dc=com givenName: Torvlobnor telephoneNumber: 545-4563 -# refldap://localhost:9010/dc=example,dc=com??one +dn: cn=Akakiy Zinberstein,dc=example,dc=com +objectClass: inetOrgPerson +cn: Akakiy Zinberstein +sn: Zinberstein +givenName: Akakiy # Testing subtree search... dn: documentTitle=book1,dc=example,dc=com @@ -57,6 +63,8 @@ documentTitle: book2 documentAuthor: cn=Mitya Kovalev,dc=example,dc=com documentIdentifier: document 2 +# refldap://localhost:9010/dc=example,dc=com??sub + dn: dc=example,dc=com objectClass: organization objectClass: dcObject @@ -81,7 +89,11 @@ seeAlso: documentTitle=book1,dc=example,dc=com givenName: Torvlobnor telephoneNumber: 545-4563 -# refldap://localhost:9010/dc=example,dc=com??sub +dn: cn=Akakiy Zinberstein,dc=example,dc=com +objectClass: inetOrgPerson +cn: Akakiy Zinberstein +sn: Zinberstein +givenName: Akakiy # Testing subtree search with manageDSAit... dn: documentTitle=book1,dc=example,dc=com @@ -99,6 +111,12 @@ documentTitle: book2 documentAuthor: cn=Mitya Kovalev,dc=example,dc=com documentIdentifier: document 2 +dn: ou=Referral,dc=example,dc=com +objectClass: referral +objectClass: extensibleObject +ou: Referral +ref: ldap://localhost:9010/ + dn: dc=example,dc=com objectClass: organization objectClass: dcObject @@ -125,14 +143,14 @@ telephoneNumber: 545-4563 dn: cn=Akakiy Zinberstein,dc=example,dc=com objectClass: inetOrgPerson -objectClass: referral cn: Akakiy Zinberstein sn: Zinberstein -ref: ldap://localhost:9010/ givenName: Akakiy # Testing invalid filter... # Testing exact search... +# refldap://localhost:9010/dc=example,dc=com??sub + dn: cn=Mitya Kovalev,dc=example,dc=com objectClass: inetOrgPerson cn: Mitya Kovalev @@ -144,6 +162,8 @@ telephoneNumber: 222-3234 telephoneNumber: 332-2334 # Testing substrings initial search... +# refldap://localhost:9010/dc=example,dc=com??sub + dn: cn=Mitya Kovalev,dc=example,dc=com objectClass: inetOrgPerson cn: Mitya Kovalev @@ -155,6 +175,8 @@ telephoneNumber: 222-3234 telephoneNumber: 332-2334 # Testing substrings any search... +# refldap://localhost:9010/dc=example,dc=com??sub + dn: cn=Mitya Kovalev,dc=example,dc=com objectClass: inetOrgPerson cn: Mitya Kovalev @@ -166,6 +188,8 @@ telephoneNumber: 222-3234 telephoneNumber: 332-2334 # Testing substrings final search... +# refldap://localhost:9010/dc=example,dc=com??sub + dn: cn=Mitya Kovalev,dc=example,dc=com objectClass: inetOrgPerson cn: Mitya Kovalev @@ -177,6 +201,8 @@ telephoneNumber: 222-3234 telephoneNumber: 332-2334 # Testing approx search... +# refldap://localhost:9010/dc=example,dc=com??sub + dn: cn=Mitya Kovalev,dc=example,dc=com objectClass: inetOrgPerson cn: Mitya Kovalev @@ -188,6 +214,8 @@ telephoneNumber: 222-3234 telephoneNumber: 332-2334 # Testing extensible filter search... +# refldap://localhost:9010/dc=example,dc=com??sub + dn: cn=Mitya Kovalev,dc=example,dc=com objectClass: inetOrgPerson cn: Mitya Kovalev @@ -199,6 +227,8 @@ telephoneNumber: 222-3234 telephoneNumber: 332-2334 # Testing search for telephoneNumber... +# refldap://localhost:9010/dc=example,dc=com??sub + dn: cn=Mitya Kovalev,dc=example,dc=com objectClass: inetOrgPerson cn: Mitya Kovalev @@ -210,6 +240,8 @@ telephoneNumber: 222-3234 telephoneNumber: 332-2334 # Testing AND search... +# refldap://localhost:9010/dc=example,dc=com??sub + dn: cn=Mitya Kovalev,dc=example,dc=com objectClass: inetOrgPerson cn: Mitya Kovalev @@ -228,6 +260,8 @@ o: Example dc: example # Testing OR search... +# refldap://localhost:9010/dc=example,dc=com??sub + dn: cn=Mitya Kovalev,dc=example,dc=com objectClass: inetOrgPerson cn: Mitya Kovalev @@ -269,7 +303,11 @@ seeAlso: documentTitle=book1,dc=example,dc=com givenName: Torvlobnor telephoneNumber: 545-4563 -# refldap://localhost:9010/dc=example,dc=com??sub +dn: cn=Akakiy Zinberstein,dc=example,dc=com +objectClass: inetOrgPerson +cn: Akakiy Zinberstein +sn: Zinberstein +givenName: Akakiy # Testing NOT search on objectClass... dn: documentTitle=book1,dc=example,dc=com @@ -287,6 +325,8 @@ documentTitle: book2 documentAuthor: cn=Mitya Kovalev,dc=example,dc=com documentIdentifier: document 2 +# refldap://localhost:9010/dc=example,dc=com??sub + dn: dc=example,dc=com objectClass: organization objectClass: dcObject @@ -309,6 +349,8 @@ documentTitle: book2 documentAuthor: cn=Mitya Kovalev,dc=example,dc=com documentIdentifier: document 2 +# refldap://localhost:9010/dc=example,dc=com??sub + dn: cn=Mitya Kovalev,dc=example,dc=com objectClass: inetOrgPerson cn: Mitya Kovalev @@ -327,7 +369,11 @@ seeAlso: documentTitle=book1,dc=example,dc=com givenName: Torvlobnor telephoneNumber: 545-4563 -# refldap://localhost:9010/dc=example,dc=com??sub +dn: cn=Akakiy Zinberstein,dc=example,dc=com +objectClass: inetOrgPerson +cn: Akakiy Zinberstein +sn: Zinberstein +givenName: Akakiy # Testing attribute inheritance in filter... dn: dc=example,dc=com @@ -355,7 +401,11 @@ seeAlso: documentTitle=book1,dc=example,dc=com givenName: Torvlobnor telephoneNumber: 545-4563 -# refldap://localhost:9010/dc=example,dc=com??sub +dn: cn=Akakiy Zinberstein,dc=example,dc=com +objectClass: inetOrgPerson +cn: Akakiy Zinberstein +sn: Zinberstein +givenName: Akakiy # Testing "auxiliary" objectClass in filter... dn: dc=example,dc=com @@ -365,14 +415,14 @@ o: Example dc: example # Testing hasSubordinates in filter... +# refldap://localhost:9010/dc=example,dc=com??sub + dn: dc=example,dc=com objectClass: organization objectClass: dcObject o: Example dc: example -# refldap://localhost:9010/dc=example,dc=com??sub - # Testing entryUUID in filter... dn: cn=Mitya Kovalev,dc=example,dc=com objectClass: inetOrgPerson @@ -385,6 +435,8 @@ telephoneNumber: 222-3234 telephoneNumber: 332-2334 # Testing attribute inheritance in requested attributes... +# refldap://localhost:9010/dc=example,dc=com??sub + dn: cn=Mitya Kovalev,dc=example,dc=com cn: Mitya Kovalev sn: Kovalev @@ -397,6 +449,8 @@ objectClass: document dn: documentTitle=book2,dc=example,dc=com objectClass: document +# refldap://localhost:9010/dc=example,dc=com??sub + dn: dc=example,dc=com objectClass: organization objectClass: dcObject @@ -407,7 +461,8 @@ objectClass: inetOrgPerson dn: cn=Torvlobnor Puzdoy,dc=example,dc=com objectClass: inetOrgPerson -# refldap://localhost:9010/dc=example,dc=com??sub +dn: cn=Akakiy Zinberstein,dc=example,dc=com +objectClass: inetOrgPerson # Testing operational attributes in request... dn: documentTitle=book1,dc=example,dc=com @@ -424,6 +479,8 @@ subschemaSubentry: cn=Subschema hasSubordinates: FALSE entryUUID: 00000002-0000-0002-0000-000000000000 +# refldap://localhost:9010/dc=example,dc=com??sub + dn: dc=example,dc=com structuralObjectClass: organization entryDN: dc=example,dc=com @@ -445,5 +502,10 @@ subschemaSubentry: cn=Subschema hasSubordinates: FALSE entryUUID: 00000001-0000-0002-0000-000000000000 -# refldap://localhost:9010/dc=example,dc=com??sub +dn: cn=Akakiy Zinberstein,dc=example,dc=com +structuralObjectClass: inetOrgPerson +entryDN: cn=Akakiy Zinberstein,dc=example,dc=com +subschemaSubentry: cn=Subschema +hasSubordinates: FALSE +entryUUID: 00000001-0000-0003-0000-000000000000 diff --git a/tests/data/sql-write.out b/tests/data/sql-write.out index a45eac4437..4573653d2d 100644 --- a/tests/data/sql-write.out +++ b/tests/data/sql-write.out @@ -1,4 +1,10 @@ # Using ldapsearch to retrieve all the entries... +dn: cn=Akakiy Zinberstein,dc=example,dc=com +objectClass: inetOrgPerson +cn: Akakiy Zinberstein +sn: Zinberstein +givenName: Akakiy + dn: documentTitle=book1,dc=example,dc=com objectClass: document description: abstract1 @@ -41,6 +47,12 @@ telephoneNumber: 545-4563 # refldap://localhost:9010/dc=example,dc=com??sub # Using ldapsearch to retrieve all the entries... +dn: cn=Akakiy Zinberstein,dc=example,dc=com +objectClass: inetOrgPerson +cn: Akakiy Zinberstein +sn: Zinberstein +givenName: Akakiy + dn: o=An Org,dc=example,dc=com objectClass: organization o: An Org @@ -130,6 +142,12 @@ documentIdentifier: document 3 # refldap://localhost:9010/dc=example,dc=com??sub # Using ldapsearch to retrieve all the entries... +dn: cn=Akakiy Zinberstein,dc=example,dc=com +objectClass: inetOrgPerson +cn: Akakiy Zinberstein +sn: Zinberstein +givenName: Akakiy + dn: o=An Org,dc=example,dc=com objectClass: organization o: An Org @@ -222,6 +240,12 @@ documentIdentifier: document 3 # refldap://localhost:9010/dc=example,dc=com??sub # Using ldapsearch to retrieve all the entries... +dn: cn=Akakiy Zinberstein,dc=example,dc=com +objectClass: inetOrgPerson +cn: Akakiy Zinberstein +sn: Zinberstein +givenName: Akakiy + dn: o=An Org,dc=example,dc=com objectClass: organization o: An Org @@ -289,6 +313,12 @@ documentIdentifier: document 3 # refldap://localhost:9010/dc=example,dc=com??sub # Using ldapsearch to retrieve all the entries... +dn: cn=Akakiy Zinberstein,dc=example,dc=com +objectClass: inetOrgPerson +cn: Akakiy Zinberstein +sn: Zinberstein +givenName: Akakiy + dn: dc=example,dc=com objectClass: organization objectClass: dcObject @@ -356,24 +386,26 @@ documentIdentifier: document 3 # refldap://localhost:9010/dc=example,dc=com??sub # Using ldapsearch to retrieve the modified entry... -dn: cn=Akakiy Zinberstein,dc=example,dc=com -objectClass: inetOrgPerson +dn: ou=Referral,dc=example,dc=com objectClass: referral -cn: Akakiy Zinberstein -sn: Zinberstein +objectClass: extensibleObject +ou: Referral ref: ldap://localhost:9009/ -givenName: Akakiy # Using ldapsearch to retrieve the renamed entry... -dn: cn=Akakiy Zinber,dc=example,dc=com -objectClass: inetOrgPerson +dn: ou=Renamed Referral,dc=example,dc=com objectClass: referral -cn: Akakiy Zinber -sn: Zinber +objectClass: extensibleObject +ou: Renamed Referral ref: ldap://localhost:9009/ -givenName: Akakiy # Using ldapsearch to retrieve all the entries... +dn: cn=Akakiy Zinberstein,dc=example,dc=com +objectClass: inetOrgPerson +cn: Akakiy Zinberstein +sn: Zinberstein +givenName: Akakiy + dn: dc=example,dc=com objectClass: organization objectClass: dcObject @@ -438,3 +470,5 @@ documentTitle: War and Peace documentAuthor: cn=Lev Tolstoij,dc=subnet,dc=example,dc=com documentIdentifier: document 3 +# refldap://localhost:9009/dc=example,dc=com??sub + diff --git a/tests/scripts/sql-test900-write b/tests/scripts/sql-test900-write index c692e1e26d..549b79b97b 100755 --- a/tests/scripts/sql-test900-write +++ b/tests/scripts/sql-test900-write @@ -336,7 +336,7 @@ EOMODS -h $LOCALHOST -p $PORT1 >> $TESTOUT 2>&1 << EOMODS version: 1 -dn: cn=Should Fail,cn=Akakiy Zinberstein,${BASEDN} +dn: cn=Should Fail,ou=Referral,${BASEDN} changetype: add objectClass: inetOrgPerson cn: Should Fail @@ -356,7 +356,7 @@ EOMODS -h $LOCALHOST -p $PORT1 >> $TESTOUT 2>&1 << EOMODS version: 1 -dn: cn=Akakiy Zinberstein,${BASEDN} +dn: ou=Referral,${BASEDN} changetype: modify replace: ref ref: ldap://localhost:9009/ @@ -375,9 +375,9 @@ EOMODS -h $LOCALHOST -p $PORT1 >> $TESTOUT 2>&1 << EOMODS version: 1 -dn: cn=Akakiy Zinberstein,${BASEDN} +dn: ou=Referral,${BASEDN} changetype: modrdn -newrdn: cn=Akakiy Zinber +newrdn: ou=Renamed Referral deleteoldrdn: 1 EOMODS @@ -393,7 +393,7 @@ EOMODS -h $LOCALHOST -p $PORT1 >> $TESTOUT 2>&1 << EOMODS version: 1 -dn: cn=Akakiy Zinberstein,${BASEDN} +dn: ou=Referral,${BASEDN} changetype: delete EOMODS @@ -404,12 +404,32 @@ EOMODS exit $RC fi + echo "Adding a referral..." + $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \ + -h $LOCALHOST -p $PORT1 -M >> $TESTOUT 2>&1 << EOMODS +version: 1 + +dn: ou=Another Referral,${BASEDN} +changetype: add +objectClass: referral +objectClass: extensibleObject +ou: Another Referral +ref: ldap://localhost:9009/ +EOMODS + + RC=$? + if test $RC != 0 ; then + echo "ldapmodify failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC + fi + echo "Modifying a referral with manageDSAit..." $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \ -h $LOCALHOST -p $PORT1 -M >> $TESTOUT 2>&1 << EOMODS version: 1 -dn: cn=Akakiy Zinberstein,${BASEDN} +dn: ou=Referral,${BASEDN} changetype: modify replace: ref ref: ldap://localhost:9009/ @@ -425,7 +445,7 @@ EOMODS echo "Using ldapsearch to retrieve the modified entry..." echo "# Using ldapsearch to retrieve the modified entry..." >> $SEARCHOUT - $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT1 -b "cn=Akakiy Zinberstein,$BASEDN" -M \ + $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT1 -b "ou=Referral,$BASEDN" -M \ "objectClass=*" '*' ref >> $SEARCHOUT 2>&1 RC=$? @@ -440,9 +460,9 @@ EOMODS -h $LOCALHOST -p $PORT1 -M >> $TESTOUT 2>&1 << EOMODS version: 1 -dn: cn=Akakiy Zinberstein,${BASEDN} +dn: ou=Referral,${BASEDN} changetype: modrdn -newrdn: cn=Akakiy Zinber +newrdn: ou=Renamed Referral deleteoldrdn: 1 EOMODS @@ -455,7 +475,7 @@ EOMODS echo "Using ldapsearch to retrieve the renamed entry..." echo "# Using ldapsearch to retrieve the renamed entry..." >> $SEARCHOUT - $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT1 -b "cn=Akakiy Zinber,$BASEDN" -M \ + $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT1 -b "ou=Renamed Referral,$BASEDN" -M \ "objectClass=*" '*' ref >> $SEARCHOUT 2>&1 RC=$? @@ -470,7 +490,7 @@ EOMODS -h $LOCALHOST -p $PORT1 -M >> $TESTOUT 2>&1 << EOMODS version: 1 -dn: cn=Akakiy Zinber,${BASEDN} +dn: ou=Renamed Referral,${BASEDN} changetype: delete EOMODS -- 2.39.5