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
+);
+
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');
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
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
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
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';
+
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
#######################################################################
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
# 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
# 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
# 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
# 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
# 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
documentAuthor: cn=Lev Tolstoij,dc=subnet,dc=example,dc=com
documentIdentifier: document 3
+# refldap://localhost:9009/dc=example,dc=com??sub
+
-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
-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/
-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
-h $LOCALHOST -p $PORT1 >> $TESTOUT 2>&1 << EOMODS
version: 1
-dn: cn=Akakiy Zinberstein,${BASEDN}
+dn: ou=Referral,${BASEDN}
changetype: delete
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/
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=$?
-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
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=$?
-h $LOCALHOST -p $PORT1 -M >> $TESTOUT 2>&1 << EOMODS
version: 1
-dn: cn=Akakiy Zinber,${BASEDN}
+dn: ou=Renamed Referral,${BASEDN}
changetype: delete
EOMODS