Commit d252d9c5 authored by Pierangelo Masarati's avatar Pierangelo Masarati
Browse files

map referrals in regular metadata structure (need to remove some of the specific code)

parent 08d4af04
......@@ -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
);
......@@ -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');
......@@ -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';
......@@ -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
#######################################################################
......
......@@ -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
# 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
......@@ -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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment