The Subject API search filter by status in Grouper / Subject API v2.1.4+ allows free-form subject searches to only return certain status
There are three types of subject API searches: by id, by identifier, and free-form. This does not affect the searches by id or identifier, only free-form. Free-form searches are generally done by users on UI's when looking to add users to groups. If by default the source filters out inactive users, then inactive users will not accidentally get added to groups (or permissions or privileges).
Note: this is available in the LDAP and JDBC2 source, but not the JDBC source.
Using
Its difficult to explain how to use this in a UI, since the labels and values will be custom to your institution. See your institution's Grouper documentation for what these labels are.
For example, lets assume the "user label" for status is "status", and the values can be "all, active, inactive, pending". By default, the filter might be "status!=inactive"
In your free-form search, you can use for example:
John Smith
That would internally be translated to: "john smith status!=inactive" for your sources which have status configured. For other sources it will search "John Smith"
The syntax is the status label, then
= equals != not equals <> not equals (same as !=)
then a value. Only one expression can be used, and only one value. If multiple expressions are used, then the first one will be used, the others will be ignored. The expression can appear anywhere in the search entry.
John status=all Smith // will search "John Smith" in all sources
status=inactive john smith // will search "john smith" in all sources except the status source where it will search "john smith" with status inactive
The labels are not case-sensitive
John Smith Status!=PenDing //will search "John Smith" in all sources except the status sources, where it searchs "John Smith" with status not equal to pending
If the optional list of valid status labels are not configured, then invalid status values will return no results
John Smith Status!=somethingWhat //will search "John Smith" in all sources except the status source, which will not find any results for the invalid status
If the optional list of valid status labels are configured, then invalid status values will return all results. This is because multiple sources could have multiple status labels, and it fails open. So this configuration is not recommended.
John Smith Status!=somethingWhat //will search "John Smith" in all sources since this is not a valid status label for the status source
Note: status labels and values must be alphanumeric, underscore, or dash
Configuration
The configuration is the same for the JDBC2 or LDAP source. In the sources.xml, have a section like this:
<!-- ########################## STATUS SECTION for searches to filter out inactives and allow the user to filter by status with e.g. status=all this is optional, and advanced --> <!-- column or attribute which represents the status --> <init-param> <param-name>statusDatastoreFieldName</param-name> <param-value>status</param-value> </init-param> <!-- search string from user which represents the status. e.g. status=active --> <init-param> <param-name>statusLabel</param-name> <param-value>status</param-value> </init-param> <!-- available statuses from screen (if not specified, any will be allowed). comma separated list. Note, this is optional and you probably dont want to configure it, it is mostly necessary when you have multiple sources with statuses... if someone types an invalid status and you have this configured, it will not filter by it --> <!-- <init-param> <param-name>statusesFromUser<param-name> <param-value>Active, Inactive, Pending, All</param-value> </init-param> --> <!-- all label from the user --> <init-param> <param-name>statusAllFromUser</param-name> <param-value>All</param-value> </init-param> <!-- if no status is specified, this will be used (e.g. for active only). Note, the value should be of the form the user would type in --> <init-param> <param-name>statusSearchDefault</param-name> <param-value>status=active</param-value> </init-param> <!-- translate between screen values of status, and the data store value. Increment the 0 to 1, 2, etc for more translations. so the user could enter: status=active, and that could translate to status_col=A. The 'user' is what the user types in, the 'datastore' is what is in the datastore. The user part is not case-sensitive. Note, this could be a many to one --> <init-param> <param-name>statusTranslateUser0</param-name> <param-value>active</param-value> </init-param> <init-param> <param-name>statusTranslateDatastore0</param-name> <param-value>A</param-value> </init-param> <init-param> <param-name>statusTranslateUser1</param-name> <param-value>inactive</param-value> </init-param> <init-param> <param-name>statusTranslateDatastore1</param-name> <param-value>I</param-value> </init-param> <init-param> <param-name>statusTranslateUser2</param-name> <param-value>pending</param-value> </init-param> <init-param> <param-name>statusTranslateDatastore2</param-name> <param-value>P</param-value> </init-param> <!-- ########################## END STATUS SECTION -->
Note, to see log messages, set this in the log4j.properties
## subject debug logging log4j.logger.edu.internet2.middleware.subject = DEBUG
sdf
Examples
JDBC2 sources.xml config
<source adapterClass="edu.internet2.middleware.subject.provider.JDBCSourceAdapter2"> <!-- CREATE TABLE person_source_v ( penn_id varchar(50) NOT NULL, name varchar(50) default NULL, email varchar(200) default NULL, description varchar(50) default NULL, pennname varchar(50) default NULL, description_lower varchar(50) default NULL, STATUS VARCHAR2(20 CHAR), PRIMARY KEY (penn_id) ); Insert into GROUPER2_1.PERSON_SOURCE_V (PENN_ID, NAME, EMAIL, DESCRIPTION, PENNNAME, DESCRIPTION_LOWER, STATUS) Values ('12345678', 'John Smith', NULL, 'John Smith', 'netmon', 'netmon, 10039438', 'A'); Insert into GROUPER2_1.PERSON_SOURCE_V (PENN_ID, NAME, EMAIL, DESCRIPTION, PENNNAME, DESCRIPTION_LOWER, STATUS) Values ('12345679', 'harveycg', NULL, 'harveycg', 'harveycg', 'harveycg, harveycg, 12345679', 'I'); Insert into GROUPER2_1.PERSON_SOURCE_V (PENN_ID, NAME, EMAIL, DESCRIPTION, PENNNAME, DESCRIPTION_LOWER, STATUS) Values ('22345678', 'bwh', NULL, 'bwh', 'bwh', 'bwh, bwh, 22345678', 'A'); Insert into GROUPER2_1.PERSON_SOURCE_V (PENN_ID, NAME, EMAIL, DESCRIPTION, PENNNAME, DESCRIPTION_LOWER, STATUS) Values ('13345678', 'convery', NULL, 'convery', 'convery', 'convery, convery, 13345678', 'I'); Insert into GROUPER2_1.PERSON_SOURCE_V (PENN_ID, NAME, EMAIL, DESCRIPTION, PENNNAME, DESCRIPTION_LOWER, STATUS) Values ('10021368', 'Chris Hyzer', NULL, 'Chris Hyzer', 'mchyzer', 'chris hyzer, mchyzer, 10021368', 'A'); Insert into GROUPER2_1.PERSON_SOURCE_V (PENN_ID, NAME, EMAIL, DESCRIPTION, PENNNAME, DESCRIPTION_LOWER, STATUS) Values ('10039438', 'John Smith', NULL, 'John Smith', 'jsmith', 'john smith, jsmith, 10039438', 'P'); COMMIT; --> <id>pennperson</id> <name>Penn person</name> <type>person</type> <init-param> <param-name>jdbcConnectionProvider</param-name> <param-value>edu.internet2.middleware.grouper.subj.GrouperJdbcConnectionProvider</param-value> </init-param> <init-param> <param-name>maxResults</param-name> <param-value>1000</param-value> </init-param> <init-param> <param-name>dbTableOrView</param-name> <param-value>person_source_v</param-value> </init-param> <init-param> <param-name>subjectIdCol</param-name> <param-value>penn_id</param-value> </init-param> <init-param> <param-name>nameCol</param-name> <param-value>name</param-value> </init-param> <init-param> <param-name>descriptionCol</param-name> <param-value>description</param-value> </init-param> <init-param> <!-- search col where general searches take place, lower case --> <param-name>lowerSearchCol</param-name> <param-value>description_lower</param-value> </init-param> <init-param> <!-- optional col if you want the search results sorted in the API (note, UI might override) --> <param-name>defaultSortCol</param-name> <param-value>description</param-value> </init-param> <init-param> <!-- col which identifies the row, perhaps not subjectId --> <param-name>subjectIdentifierCol0</param-name> <param-value>pennname</param-value> </init-param> <init-param> <param-name>subjectIdentifierCol1</param-name> <param-value>penn_id</param-value> </init-param> <!-- now you can count up from 0 to N of attributes for various cols --> <init-param> <param-name>subjectAttributeCol0</param-name> <param-value>pennname</param-value> </init-param> <init-param> <param-name>subjectAttributeName0</param-name> <param-value>PENNNAME</param-value> </init-param> <init-param> <param-name>subjectAttributeCol1</param-name> <param-value>email</param-value> </init-param> <init-param> <param-name>subjectAttributeName1</param-name> <param-value>EMAIL</param-value> </init-param> <init-param> <param-name>sortAttribute0</param-name> <param-value>description</param-value> </init-param> <init-param> <param-name>searchAttribute0</param-name> <param-value>description_lower</param-value> </init-param> <!-- ########################## STATUS SECTION for searches to filter out inactives and allow the user to filter by status with e.g. status=all this is optional, and advanced --> <!-- column or attribute which represents the status --> <init-param> <param-name>statusDatastoreFieldName</param-name> <param-value>status</param-value> </init-param> <!-- search string from user which represents the status. e.g. status=active --> <init-param> <param-name>statusLabel</param-name> <param-value>status</param-value> </init-param> <!-- available statuses from screen (if not specified, any will be allowed). comma separated list. Note, this is optional and you probably dont want to configure it, it is mostly necessary when you have multiple sources with statuses... if someone types an invalid status and you have this configured, it will not filter by it --> <!-- <init-param> <param-name>statusesFromUser<param-name> <param-value>Active, Inactive, Pending, All</param-value> </init-param> --> <!-- all label from the user --> <init-param> <param-name>statusAllFromUser</param-name> <param-value>All</param-value> </init-param> <!-- if no status is specified, this will be used (e.g. for active only). Note, the value should be of the form the user would type in --> <init-param> <param-name>statusSearchDefault</param-name> <param-value>status=active</param-value> </init-param> <!-- translate between screen values of status, and the data store value. Increment the 0 to 1, 2, etc for more translations. so the user could enter: status=active, and that could translate to status_col=A. The 'user' is what the user types in, the 'datastore' is what is in the datastore. The user part is not case-sensitive. Note, this could be a many to one --> <init-param> <param-name>statusTranslateUser0</param-name> <param-value>active</param-value> </init-param> <init-param> <param-name>statusTranslateDatastore0</param-name> <param-value>A</param-value> </init-param> <init-param> <param-name>statusTranslateUser1</param-name> <param-value>inactive</param-value> </init-param> <init-param> <param-name>statusTranslateDatastore1</param-name> <param-value>I</param-value> </init-param> <init-param> <param-name>statusTranslateUser2</param-name> <param-value>pending</param-value> </init-param> <init-param> <param-name>statusTranslateDatastore2</param-name> <param-value>P</param-value> </init-param> <!-- ########################## END STATUS SECTION --> </source>
LDAP sources.xml config (note, we dont have status, so we can use affiliation as an example, STAFF means active
<source adapterClass="edu.internet2.middleware.grouper.subj.GrouperJndiSourceAdapter"> <id>pennDirectory</id> <name>Penn Directory</name> <type>person</type> <init-param> <param-name>INITIAL_CONTEXT_FACTORY</param-name> <param-value>com.sun.jndi.ldap.LdapCtxFactory</param-value> </init-param> <init-param> <param-name>PROVIDER_URL</param-name> <param-value>ldap://directory.school.edu:389</param-value> </init-param> <init-param> <param-name>SECURITY_AUTHENTICATION</param-name> <param-value>none</param-value> </init-param> <!-- <init-param> <param-name>SECURITY_PRINCIPAL</param-name> <param-value>cn=Manager,dc=example,dc=edu</param-value> </init-param> <init-param> <param-name>SECURITY_CREDENTIALS</param-name> <param-value>secret</param-value> </init-param> --> <init-param> <param-name>SubjectID_AttributeType</param-name> <param-value>uid</param-value> </init-param> <init-param> <param-name>SubjectID_formatToLowerCase</param-name> <param-value>false</param-value> </init-param> <init-param> <param-name>Name_AttributeType</param-name> <param-value>cn</param-value> </init-param> <init-param> <param-name>Description_AttributeType</param-name> <param-value>displayName</param-value> </init-param> <!-- /// Scope Values can be: OBJECT_SCOPE, ONELEVEL_SCOPE, SUBTREE_SCOPE /// For filter use --> <search> <searchType>searchSubject</searchType> <param> <param-name>filter</param-name> <param-value> (& (uid=%TERM%) (objectclass=eduPerson)) </param-value> </param> <param> <param-name>scope</param-name> <param-value> SUBTREE_SCOPE </param-value> </param> <param> <param-name>base</param-name> <param-value> ou=people,dc=school,dc=edu </param-value> </param> </search> <search> <searchType>searchSubjectByIdentifier</searchType> <param> <param-name>filter</param-name> <param-value> (& (uid=%TERM%) (objectclass=eduPerson)) </param-value> </param> <param> <param-name>scope</param-name> <param-value> SUBTREE_SCOPE </param-value> </param> <param> <param-name>base</param-name> <param-value> ou=people,dc=school,dc=edu </param-value> </param> </search> <search> <searchType>search</searchType> <param> <param-name>filter</param-name> <param-value> (& (|(uid=%TERM%)(|(cn=*%TERM%*)(displayName=*%TERM%*)))(objectclass=eduPerson)) </param-value> </param> <param> <param-name>scope</param-name> <param-value> SUBTREE_SCOPE </param-value> </param> <param> <param-name>base</param-name> <param-value> ou=people,dc=school,dc=edu </param-value> </param> </search> <init-param> <param-name>subjectVirtualAttribute_0_searchAttribute0</param-name> <param-value>${subjectUtils.defaultIfBlank(subject.getAttributeValueOrCommaSeparated('uid'), "")},${subjectUtils.defaultIfBlank(subject.getAttributeValueOrCommaSeparated('cn'), "")},${subjectUtils.defaultIfBlank(subject.getAttributeValueOrCommaSeparated('displayName'), "")}</param-value> </init-param> <init-param> <param-name>sortAttribute0</param-name> <param-value>cn</param-value> </init-param> <init-param> <param-name>searchAttribute0</param-name> <param-value>searchAttribute0</param-value> </init-param> <!-- ########################## STATUS SECTION for searches to filter out inactives and allow the user to filter by status with e.g. status=all this is optional, and advanced --> <!-- column or attribute which represents the status --> <init-param> <param-name>statusDatastoreFieldName</param-name> <param-value>eduPersonAffiliation</param-value> </init-param> <!-- search string from user which represents the status. e.g. status=active --> <init-param> <param-name>statusLabel</param-name> <param-value>status</param-value> </init-param> <!-- available statuses from screen (if not specified, any will be allowed). comma separated list. Note, this is optional and you probably dont want to configure it, it is mostly necessary when you have multiple sources with statuses... if someone types an invalid status and you have this configured, it will not filter by it - - > <!- - <init-param> <param-name>statusesFromUser<param-name> <param-value>Active, Inactive, Pending, All</param-value> </init-param> - - > <!- - all label from the user --> <init-param> <param-name>statusAllFromUser</param-name> <param-value>All</param-value> </init-param> <!-- if no status is specified, this will be used (e.g. for active only). Note, the value should be of the form the user would type in --> <init-param> <param-name>statusSearchDefault</param-name> <param-value>status=staff</param-value> </init-param> <!-- translate between screen values of status, and the data store value. Increment the 0 to 1, 2, etc for more translations. so the user could enter: status=active, and that could translate to status_col=A. The 'user' is what the user types in, the 'datastore' is what is in the datastore. The user part is not case-sensitive. Note, this could be a many to one --> <init-param> <param-name>statusTranslateUser0</param-name> <param-value>staff</param-value> </init-param> <init-param> <param-name>statusTranslateDatastore0</param-name> <param-value>STAF</param-value> </init-param> <init-param> <param-name>statusTranslateUser1</param-name> <param-value>faculty</param-value> </init-param> <init-param> <param-name>statusTranslateDatastore1</param-name> <param-value>FAC</param-value> </init-param> <init-param> <param-name>statusTranslateUser2</param-name> <param-value>student</param-value> </init-param> <init-param> <param-name>statusTranslateDatastore2</param-name> <param-value>STU</param-value> </init-param> <!-- ########################## END STATUS SECTION --> <internal-attribute>searchAttribute0</internal-attribute> <!-- ///Attributes you would like to display when doing a search --> <attribute>cn</attribute> <attribute>uid</attribute> <attribute>displayName</attribute> </source>
Here is a GSH test
Type help() for instructions gsh 0% grouperSession = GrouperSession.startRootSession(); edu.internet2.middleware.grouper.GrouperSession: 5db68c7a84604969b69a14d72e22efde,'GrouperSystem','application' gsh 1% SubjectFinder.findById("12345678", false); 2013-04-24 10:25:50,294: [main] DEBUG LdapSourceAdapter.getLdapResultsHelper(650) - - searchType: searchSubject, filter: (& (uid=12345678) (objectclass=eduPerson)) 2013-04-24 10:25:55,205: [main] DEBUG JDBCSourceAdapter2.search(838) - - Query returned 1, select penn_id, name, description, description_lower, pennname, email from (select penn_id,name,description,description_lower,pennname,email from person_source_v where penn_id in (?)) where rownum <= 1001, ArrayList size: 1: [0]: 12345678 2013-04-24 10:25:55,209: [main] DEBUG JDBCSourceAdapter2.search(838) - - Query returned 0, select uuid,name,description,search_string_lower,identifier,institution,email from grouper_ext_subj_v where uuid in (?), ArrayList size: 1: [0]: 12345678 subject: id='12345678' type='person' source='pennperson' name='John Smith' gsh 2% SubjectFinder.findById("12345679", false); 2013-04-24 10:26:20,890: [main] DEBUG LdapSourceAdapter.getLdapResultsHelper(650) - - searchType: searchSubject, filter: (& (uid=12345679) (objectclass=eduPerson)) 2013-04-24 10:26:25,859: [main] DEBUG JDBCSourceAdapter2.search(838) - - Query returned 1, select penn_id, name, description, description_lower, pennname, email from (select penn_id,name,description,description_lower,pennname,email from person_source_v where penn_id in (?)) where rownum <= 1001, ArrayList size: 1: [0]: 12345679 2013-04-24 10:26:25,862: [main] DEBUG JDBCSourceAdapter2.search(838) - - Query returned 0, select uuid,name,description,search_string_lower,identifier,institution,email from grouper_ext_subj_v where uuid in (?), ArrayList size: 1: [0]: 12345679 subject: id='12345679' type='person' source='pennperson' name='harveycg' gsh 3% SubjectFinder.findById("mchyzer", false); 2013-04-24 10:26:47,331: [main] DEBUG LdapSourceAdapter.getLdapResultsHelper(650) - - searchType: searchSubject, filter: (& (uid=mchyzer) (objectclass=eduPerson)) 2013-04-24 10:26:52,207: [main] DEBUG LdapSubject.<init>(63) - - LdapSubject Name = Hyzer, Chris 2013-04-24 10:26:52,220: [main] DEBUG JDBCSourceAdapter2.search(838) - - Query returned 0, select penn_id, name, description, description_lower, pennname, email from (select penn_id,name,description,description_lower,pennname,email from person_source_v where penn_id in (?)) where rownum <= 1001, ArrayList size: 1: [0]: mchyzer 2013-04-24 10:26:52,223: [main] DEBUG JDBCSourceAdapter2.search(838) - - Query returned 0, select uuid,name,description,search_string_lower,identifier,institution,email from grouper_ext_subj_v where uuid in (?), ArrayList size: 1: [0]: mchyzer subject: id='mchyzer' type='person' source='pennDirectory' name='Hyzer, Chris ' gsh 4% SubjectFinder.findById("jay", false); 2013-04-24 10:27:08,551: [main] DEBUG LdapSourceAdapter.getLdapResultsHelper(650) - - searchType: searchSubject, filter: (& (uid=jay) (objectclass=eduPerson)) 2013-04-24 10:27:13,534: [main] DEBUG LdapSubject.<init>(63) - - LdapSubject Name = Thrudupa, Dr. John K., PhD 2013-04-24 10:27:13,547: [main] DEBUG JDBCSourceAdapter2.search(838) - - Query returned 0, select penn_id, name, description, description_lower, pennname, email from (select penn_id,name,description,description_lower,pennname,email from person_source_v where penn_id in (?)) where rownum <= 1001, ArrayList size: 1: [0]: jay 2013-04-24 10:27:13,550: [main] DEBUG JDBCSourceAdapter2.search(838) - - Query returned 0, select uuid,name,description,search_string_lower,identifier,institution,email from grouper_ext_subj_v where uuid in (?), ArrayList size: 1: [0]: jay subject: id='jay' type='person' source='pennDirectory' name='Thrudupa, Dr. John K., PhD' gsh 5% SubjectFinder.findByIdentifierAndSource("mchyzer", "pennperson", false); 2013-04-24 10:29:24,254: [main] DEBUG JDBCSourceAdapter2.search(838) - - Query returned 1, select penn_id, name, description, description_lower, pennname, email from (select penn_id,name,description,description_lower,pennname,email from person_source_v where ( pennname = ? or penn_id = ? ) ) where rownum <= 1001, ArrayList size: 2: [0]: mchyzer [1]: mchyzer subject: id='10021368' type='person' source='pennperson' name='Chris Hyzer' gsh 6% SubjectFinder.findByIdentifierAndSource("harveycg", "pennperson", false); 2013-04-24 10:29:39,304: [main] DEBUG JDBCSourceAdapter2.search(838) - - Query returned 1, select penn_id, name, description, description_lower, pennname, email from (select penn_id,name,description,description_lower,pennname,email from person_source_v where ( pennname = ? or penn_id = ? ) ) where rownum <= 1001, ArrayList size: 2: [0]: harveycg [1]: harveycg subject: id='12345679' type='person' source='pennperson' name='harveycg' gsh 7% SubjectFinder.findByIdentifierAndSource("mchyzer", "pennDirectory", false); 2013-04-24 10:29:58,930: [main] DEBUG LdapSourceAdapter.getLdapResultsHelper(650) - - searchType: searchSubjectByIdentifier, filter: (& (uid=mchyzer) (objectclass=eduPerson)) 2013-04-24 10:30:04,001: [main] DEBUG LdapSubject.<init>(63) - - LdapSubject Name = Hyzer, Chris subject: id='mchyzer' type='person' source='pennDirectory' name='Hyzer, Chris ' gsh 8% SubjectFinder.findByIdentifierAndSource("jay", "pennDirectory", false); 2013-04-24 10:30:11,807: [main] DEBUG LdapSourceAdapter.getLdapResultsHelper(650) - - searchType: searchSubjectByIdentifier, filter: (& (uid=jay) (objectclass=eduPerson)) 2013-04-24 10:30:16,910: [main] DEBUG LdapSubject.<init>(63) - - LdapSubject Name = Thrudupa, Dr. John K., PhD subject: id='jay' type='person' source='pennDirectory' name='Thrudupa, Dr. John K., PhD' gsh 9% SubjectFinder.findAll("mchyzer"); 2013-04-24 10:31:03,371: [main] DEBUG LdapSourceAdapter.getLdapResultsHelper(645) - - searchType: search, preStatusFilter: (& (|(uid=mchyzer)(|(cn=*mchyzer*)(displayName=*mchyzer*)))(objectclass=eduPerson)), filter: (&(& (|(uid=mchyzer)(|(cn=*mchyzer*)(displayName=*mchyzer*)))(objectclass=eduPerson))(eduPersonAffiliation=STAF)) 2013-04-24 10:31:12,046: [main] DEBUG LdapSubject.<init>(63) - - LdapSubject Name = Hyzer, Chris 2013-04-24 10:31:12,047: [main] DEBUG LdapSourceAdapter.searchHelper(435) - - set has 1 subjects 2013-04-24 10:31:12,048: [main] DEBUG LdapSourceAdapter.searchHelper(436) - - first is Hyzer, Chris 2013-04-24 10:31:12,077: [main] DEBUG JDBCSourceAdapter2.search(838) - - Query returned 1, select penn_id, name, description, description_lower, pennname, email from (select penn_id,name,description,description_lower,pennname,email from person_source_v where description_lower like ? and status ='A' order by description) where rownum <= 1001, ArrayList size: 1: [0]: %mchyzer% 2013-04-24 10:31:12,079: [main] DEBUG JDBCSourceAdapter2.search(838) - - Query returned 0, select uuid,name,description,search_string_lower,identifier,institution,email from grouper_ext_subj_v where search_string_lower like ?, ArrayList size: 1: [0]: %mchyzer% subject: id='mchyzer' type='person' source='pennDirectory' name='Hyzer, Chris ' subject: id='10021368' type='person' source='pennperson' name='Chris Hyzer' gsh 10% SubjectFinder.findAll("mchyzer status=active"); 2013-04-24 10:33:20,143: [main] DEBUG LdapSourceAdapter.getLdapResultsHelper(645) - - searchType: search, preStatusFilter: (& (|(uid=mchyzer)(|(cn=*mchyzer*)(displayName=*mchyzer*)))(objectclass=eduPerson)), filter: (&(& (|(uid=mchyzer)(|(cn=*mchyzer*)(displayName=*mchyzer*)))(objectclass=eduPerson))(eduPersonAffiliation=active)) 2013-04-24 10:33:28,782: [main] DEBUG LdapSourceAdapter.searchHelper(435) - - set has 0 subjects 2013-04-24 10:33:28,815: [main] DEBUG JDBCSourceAdapter2.search(838) - - Query returned 1, select penn_id, name, description, description_lower, pennname, email from (select penn_id,name,description,description_lower,pennname,email from person_source_v where description_lower like ? and status ='A' order by description) where rownum <= 1001, ArrayList size: 1: [0]: %mchyzer% 2013-04-24 10:33:28,817: [main] DEBUG JDBCSourceAdapter2.search(838) - - Query returned 0, select uuid,name,description,search_string_lower,identifier,institution,email from grouper_ext_subj_v where search_string_lower like ?, ArrayList size: 1: [0]: %mchyzer% subject: id='10021368' type='person' source='pennperson' name='Chris Hyzer' gsh 11% SubjectFinder.findAll("mchyzer status=all"); 2013-04-24 10:33:45,454: [main] DEBUG LdapSourceAdapter.getLdapResultsHelper(650) - - searchType: search, filter: (& (|(uid=mchyzer)(|(cn=*mchyzer*)(displayName=*mchyzer*)))(objectclass=eduPerson)) 2013-04-24 10:33:53,387: [main] DEBUG LdapSubject.<init>(63) - - LdapSubject Name = Hyzer, Chris 2013-04-24 10:33:53,388: [main] DEBUG LdapSourceAdapter.searchHelper(435) - - set has 1 subjects 2013-04-24 10:33:53,388: [main] DEBUG LdapSourceAdapter.searchHelper(436) - - first is Hyzer, Chris 2013-04-24 10:33:53,416: [main] DEBUG JDBCSourceAdapter2.search(838) - - Query returned 1, select penn_id, name, description, description_lower, pennname, email from (select penn_id,name,description,description_lower,pennname,email from person_source_v where description_lower like ? order by description) where rownum <= 1001, ArrayList size: 1: [0]: %mchyzer% 2013-04-24 10:33:53,418: [main] DEBUG JDBCSourceAdapter2.search(838) - - Query returned 0, select uuid,name,description,search_string_lower,identifier,institution,email from grouper_ext_subj_v where search_string_lower like ?, ArrayList size: 1: [0]: %mchyzer% subject: id='mchyzer' type='person' source='pennDirectory' name='Hyzer, Chris ' subject: id='10021368' type='person' source='pennperson' name='Chris Hyzer' gsh 12% SubjectFinder.findAll("mchyzer status=inactive"); 2013-04-24 10:34:07,133: [main] DEBUG LdapSourceAdapter.getLdapResultsHelper(645) - - searchType: search, preStatusFilter: (& (|(uid=mchyzer)(|(cn=*mchyzer*)(displayName=*mchyzer*)))(objectclass=eduPerson)), filter: (&(& (|(uid=mchyzer)(|(cn=*mchyzer*)(displayName=*mchyzer*)))(objectclass=eduPerson))(eduPersonAffiliation=inactive)) 2013-04-24 10:34:15,775: [main] DEBUG LdapSourceAdapter.searchHelper(435) - - set has 0 subjects 2013-04-24 10:34:15,811: [main] DEBUG JDBCSourceAdapter2.search(838) - - Query returned 0, select penn_id, name, description, description_lower, pennname, email from (select penn_id,name,description,description_lower,pennname,email from person_source_v where description_lower like ? and status ='I' order by description) where rownum <= 1001, ArrayList size: 1: [0]: %mchyzer% 2013-04-24 10:34:15,815: [main] DEBUG JDBCSourceAdapter2.search(838) - - Query returned 0, select uuid,name,description,search_string_lower,identifier,institution,email from grouper_ext_subj_v where search_string_lower like ?, ArrayList size: 1: [0]: %mchyzer% gsh 13% SubjectFinder.findAll("harveycg"); 2013-04-24 10:34:53,394: [main] DEBUG LdapSourceAdapter.getLdapResultsHelper(645) - - searchType: search, preStatusFilter: (& (|(uid=harveycg)(|(cn=*harveycg*)(displayName=*harveycg*)))(objectclass=eduPerson)), filter: (&(& (|(uid=harveycg)(|(cn=*harveycg*)(displayName=*harveycg*)))(objectclass=eduPerson))(eduPersonAffiliation=STAF)) 2013-04-24 10:35:01,971: [main] DEBUG LdapSubject.<init>(63) - - LdapSubject Name = HARVEY, CHUCK GREEN 2013-04-24 10:35:01,972: [main] DEBUG LdapSourceAdapter.searchHelper(435) - - set has 1 subjects 2013-04-24 10:35:01,973: [main] DEBUG LdapSourceAdapter.searchHelper(436) - - first is HARVEY, CHUCK GREEN 2013-04-24 10:35:01,998: [main] DEBUG JDBCSourceAdapter2.search(838) - - Query returned 0, select penn_id, name, description, description_lower, pennname, email from (select penn_id,name,description,description_lower,pennname,email from person_source_v where description_lower like ? and status ='A' order by description) where rownum <= 1001, ArrayList size: 1: [0]: %harveycg% 2013-04-24 10:35:02,001: [main] DEBUG JDBCSourceAdapter2.search(838) - - Query returned 0, select uuid,name,description,search_string_lower,identifier,institution,email from grouper_ext_subj_v where search_string_lower like ?, ArrayList size: 1: [0]: %harveycg% subject: id='harveycg' type='person' source='pennDirectory' name='HARVEY, CHUCK GREEN' gsh 14% SubjectFinder.findAll("harveycg status=active"); 2013-04-24 10:35:17,865: [main] DEBUG LdapSourceAdapter.getLdapResultsHelper(645) - - searchType: search, preStatusFilter: (& (|(uid=harveycg)(|(cn=*harveycg*)(displayName=*harveycg*)))(objectclass=eduPerson)), filter: (&(& (|(uid=harveycg)(|(cn=*harveycg*)(displayName=*harveycg*)))(objectclass=eduPerson))(eduPersonAffiliation=active)) 2013-04-24 10:35:26,584: [main] DEBUG LdapSourceAdapter.searchHelper(435) - - set has 0 subjects 2013-04-24 10:35:26,612: [main] DEBUG JDBCSourceAdapter2.search(838) - - Query returned 0, select penn_id, name, description, description_lower, pennname, email from (select penn_id,name,description,description_lower,pennname,email from person_source_v where description_lower like ? and status ='A' order by description) where rownum <= 1001, ArrayList size: 1: [0]: %harveycg% 2013-04-24 10:35:26,616: [main] DEBUG JDBCSourceAdapter2.search(838) - - Query returned 0, select uuid,name,description,search_string_lower,identifier,institution,email from grouper_ext_subj_v where search_string_lower like ?, ArrayList size: 1: [0]: %harveycg% gsh 15% SubjectFinder.findAll("harveycg status=all"); 2013-04-24 10:35:27,866: [main] DEBUG LdapSourceAdapter.getLdapResultsHelper(650) - - searchType: search, filter: (& (|(uid=harveycg)(|(cn=*harveycg*)(displayName=*harveycg*)))(objectclass=eduPerson)) 2013-04-24 10:35:35,539: [main] DEBUG LdapSubject.<init>(63) - - LdapSubject Name = HARVEY, CHUCK GREEN 2013-04-24 10:35:35,540: [main] DEBUG LdapSourceAdapter.searchHelper(435) - - set has 1 subjects 2013-04-24 10:35:35,541: [main] DEBUG LdapSourceAdapter.searchHelper(436) - - first is HARVEY, CHUCK GREEN 2013-04-24 10:35:35,567: [main] DEBUG JDBCSourceAdapter2.search(838) - - Query returned 1, select penn_id, name, description, description_lower, pennname, email from (select penn_id,name,description,description_lower,pennname,email from person_source_v where description_lower like ? order by description) where rownum <= 1001, ArrayList size: 1: [0]: %harveycg% 2013-04-24 10:35:35,569: [main] DEBUG JDBCSourceAdapter2.search(838) - - Query returned 0, select uuid,name,description,search_string_lower,identifier,institution,email from grouper_ext_subj_v where search_string_lower like ?, ArrayList size: 1: [0]: %harveycg% subject: id='harveycg' type='person' source='pennDirectory' name='HARVEY, CHUCK GREEN' subject: id='12345679' type='person' source='pennperson' name='harveycg' gsh 16% SubjectFinder.findAll("harveycg status=inactive"); 2013-04-24 10:35:42,686: [main] DEBUG LdapSourceAdapter.getLdapResultsHelper(645) - - searchType: search, preStatusFilter: (& (|(uid=harveycg)(|(cn=*harveycg*)(displayName=*harveycg*)))(objectclass=eduPerson)), filter: (&(& (|(uid=harveycg)(|(cn=*harveycg*)(displayName=*harveycg*)))(objectclass=eduPerson))(eduPersonAffiliation=inactive)) 2013-04-24 10:35:51,459: [main] DEBUG LdapSourceAdapter.searchHelper(435) - - set has 0 subjects 2013-04-24 10:35:51,489: [main] DEBUG JDBCSourceAdapter2.search(838) - - Query returned 1, select penn_id, name, description, description_lower, pennname, email from (select penn_id,name,description,description_lower,pennname,email from person_source_v where description_lower like ? and status ='I' order by description) where rownum <= 1001, ArrayList size: 1: [0]: %harveycg% 2013-04-24 10:35:51,492: [main] DEBUG JDBCSourceAdapter2.search(838) - - Query returned 0, select uuid,name,description,search_string_lower,identifier,institution,email from grouper_ext_subj_v where search_string_lower like ?, ArrayList size: 1: [0]: %harveycg% subject: id='12345679' type='person' source='pennperson' name='harveycg' gsh 17% SubjectFinder.findAll("udupa"); 2013-04-24 10:36:29,153: [main] DEBUG LdapSourceAdapter.getLdapResultsHelper(645) - - searchType: search, preStatusFilter: (& (|(uid=udupa)(|(cn=*udupa*)(displayName=*udupa*)))(objectclass=eduPerson)), filter: (&(& (|(uid=udupa)(|(cn=*udupa*)(displayName=*udupa*)))(objectclass=eduPerson))(eduPersonAffiliation=STAF)) 2013-04-24 10:36:37,827: [main] DEBUG LdapSourceAdapter.searchHelper(435) - - set has 0 subjects 2013-04-24 10:36:37,849: [main] DEBUG JDBCSourceAdapter2.search(838) - - Query returned 0, select penn_id, name, description, description_lower, pennname, email from (select penn_id,name,description,description_lower,pennname,email from person_source_v where description_lower like ? and status ='A' order by description) where rownum <= 1001, ArrayList size: 1: [0]: %udupa% 2013-04-24 10:36:37,851: [main] DEBUG JDBCSourceAdapter2.search(838) - - Query returned 0, select uuid,name,description,search_string_lower,identifier,institution,email from grouper_ext_subj_v where search_string_lower like ?, ArrayList size: 1: [0]: %udupa% gsh 18% SubjectFinder.findAll("udupa status=active"); 2013-04-24 10:36:40,004: [main] DEBUG LdapSourceAdapter.getLdapResultsHelper(645) - - searchType: search, preStatusFilter: (& (|(uid=udupa)(|(cn=*udupa*)(displayName=*udupa*)))(objectclass=eduPerson)), filter: (&(& (|(uid=udupa)(|(cn=*udupa*)(displayName=*udupa*)))(objectclass=eduPerson))(eduPersonAffiliation=active)) 2013-04-24 10:36:48,672: [main] DEBUG LdapSourceAdapter.searchHelper(435) - - set has 0 subjects 2013-04-24 10:36:48,700: [main] DEBUG JDBCSourceAdapter2.search(838) - - Query returned 0, select penn_id, name, description, description_lower, pennname, email from (select penn_id,name,description,description_lower,pennname,email from person_source_v where description_lower like ? and status ='A' order by description) where rownum <= 1001, ArrayList size: 1: [0]: %udupa% 2013-04-24 10:36:48,702: [main] DEBUG JDBCSourceAdapter2.search(838) - - Query returned 0, select uuid,name,description,search_string_lower,identifier,institution,email from grouper_ext_subj_v where search_string_lower like ?, ArrayList size: 1: [0]: %udupa% gsh 19% gsh 20% SubjectFinder.findAll("udupa status=all"); 2013-04-24 10:36:50,141: [main] DEBUG LdapSourceAdapter.getLdapResultsHelper(650) - - searchType: search, filter: (& (|(uid=udupa)(|(cn=*udupa*)(displayName=*udupa*)))(objectclass=eduPerson)) 2013-04-24 10:36:58,137: [main] DEBUG LdapSubject.<init>(63) - - LdapSubject Name = Thrudupa, Dr. John K., PhD 2013-04-24 10:36:58,138: [main] DEBUG LdapSubject.<init>(63) - - LdapSubject Name = CVFUDUPAQW, FRED 2013-04-24 10:36:58,139: [main] DEBUG LdapSourceAdapter.searchHelper(435) - - set has 2 subjects 2013-04-24 10:36:58,139: [main] DEBUG LdapSourceAdapter.searchHelper(436) - - first is CVFUDUPAQW, FRED 2013-04-24 10:36:58,160: [main] DEBUG JDBCSourceAdapter2.search(838) - - Query returned 0, select penn_id, name, description, description_lower, pennname, email from (select penn_id,name,description,description_lower,pennname,email from person_source_v where description_lower like ? order by description) where rownum <= 1001, ArrayList size: 1: [0]: %udupa% 2013-04-24 10:36:58,162: [main] DEBUG JDBCSourceAdapter2.search(838) - - Query returned 0, select uuid,name,description,search_string_lower,identifier,institution,email from grouper_ext_subj_v where search_string_lower like ?, ArrayList size: 1: [0]: %udupa% subject: id='audupa' type='person' source='pennDirectory' name='CVFUDUPAQW, FRED ' subject: id='jay' type='person' source='pennDirectory' name='Thrudupa, Dr. John K., PhD' gsh 21% SubjectFinder.findAll("udupa status=faculty"); 2013-04-24 10:37:25,830: [main] DEBUG LdapSourceAdapter.getLdapResultsHelper(645) - - searchType: search, preStatusFilter: (& (|(uid=udupa)(|(cn=*udupa*)(displayName=*udupa*)))(objectclass=eduPerson)), filter: (&(& (|(uid=udupa)(|(cn=*udupa*)(displayName=*udupa*)))(objectclass=eduPerson))(eduPersonAffiliation=FAC)) 2013-04-24 10:37:34,719: [main] DEBUG LdapSubject.<init>(63) - - LdapSubject Name = Thrudupa, Dr. John K., PhD 2013-04-24 10:37:34,719: [main] DEBUG LdapSourceAdapter.searchHelper(435) - - set has 1 subjects 2013-04-24 10:37:34,720: [main] DEBUG LdapSourceAdapter.searchHelper(436) - - first is Thrudupa, Dr. John K., PhD 2013-04-24 10:37:34,750: [main] DEBUG JDBCSourceAdapter2.search(838) - - Query returned 0, select penn_id, name, description, description_lower, pennname, email from (select penn_id,name,description,description_lower,pennname,email from person_source_v where description_lower like ? and status ='faculty' order by description) where rownum <= 1001, ArrayList size: 1: [0]: %udupa% 2013-04-24 10:37:34,752: [main] DEBUG JDBCSourceAdapter2.search(838) - - Query returned 0, select uuid,name,description,search_string_lower,identifier,institution,email from grouper_ext_subj_v where search_string_lower like ?, ArrayList size: 1: [0]: %udupa% subject: id='jay' type='person' source='pennDirectory' name='Thrudupa, Dr. John K., PhD' gsh 22% SubjectFinder.findAll("udupa status!=student"); 2013-04-24 11:49:59,887: [main] DEBUG LdapSourceAdapter.getLdapResultsHelper(658) - - searchType: search, preStatusFilter: (& (|(uid=udupa)(|(cn=*udupa*)(displayName=*udupa*)))(objectclass=eduPerson)), filter: (&(& (|(uid=udupa)(|(cn=*udupa*)(displayName=*udupa*)))(objectclass=eduPerson))( ! ( eduPersonAffiliation=STU ) )) 2013-04-24 11:50:08,670: [main] DEBUG LdapSubject.<init>(63) - - LdapSubject Name = Thrudupa, Dr. John K., PhD 2013-04-24 11:50:08,671: [main] DEBUG LdapSourceAdapter.searchHelper(442) - - set has 1 subjects 2013-04-24 11:50:08,672: [main] DEBUG LdapSourceAdapter.searchHelper(443) - - first is Thrudupa, Dr. John K., PhD 2013-04-24 11:50:08,708: [main] DEBUG JDBCSourceAdapter2.search(836) - - Query returned 0, select penn_id, name, description, description_lower, pennname, email from (select penn_id,name,description,description_lower,pennname,email from person_source_v where description_lower like ? and status <> ? order by description) where rownum <= 1001, ArrayList size: 2: [0]: %udupa% [1]: student 2013-04-24 11:50:08,711: [main] DEBUG JDBCSourceAdapter2.search(836) - - Query returned 0, select uuid,name,description,search_string_lower,identifier,institution,email from grouper_ext_subj_v where search_string_lower like ?, ArrayList size: 1: [0]: %udupa% gsh 23% SubjectFinder.findAll("udupa status!=faculty"); 2013-04-24 11:51:46,359: [main] DEBUG LdapSourceAdapter.getLdapResultsHelper(658) - - searchType: search, preStatusFilter: (& (|(uid=udupa)(|(cn=*udupa*)(displayName=*udupa*)))(objectclass=eduPerson)), filter: (&(& (|(uid=udupa)(|(cn=*udupa*)(displayName=*udupa*)))(objectclass=eduPerson))( ! ( eduPersonAffiliation=FAC ) )) 2013-04-24 11:51:54,922: [main] DEBUG LdapSubject.<init>(63) - - LdapSubject Name = CVFUDUPAQW, FRED 2013-04-24 11:51:54,923: [main] DEBUG LdapSourceAdapter.searchHelper(442) - - set has 1 subjects 2013-04-24 11:51:54,924: [main] DEBUG LdapSourceAdapter.searchHelper(443) - - first is CVFUDUPAQW, FRED 2013-04-24 11:51:54,965: [main] DEBUG JDBCSourceAdapter2.search(836) - - Query returned 0, select penn_id, name, description, description_lower, pennname, email from (select penn_id,name,description,description_lower,pennname,email from person_source_v where description_lower like ? and status <> ? order by description) where rownum <= 1001, ArrayList size: 2: [0]: %udupa% [1]: faculty 2013-04-24 11:51:54,968: [main] DEBUG JDBCSourceAdapter2.search(836) - - Query returned 0, select uuid,name,description,search_string_lower,identifier,institution,email from grouper_ext_subj_v where search_string_lower like ?, ArrayList size: 1: [0]: %udupa% subject: id='4d2331277557471b8ba1d3b6583497da' type='group' source='g:gsa' name='stem1:udupa' subject: id='audupa' type='person' source='pennDirectory' name='CVFUDUPAQW, FRED ' gsh 24%
sdf
Changes to custom sources
This enhancement requires custom sources to put code in to filter out the extraneous status query part. If you want to implement status filtering in a custom source, see the examples for the JDBC2 or LDAP source. e.g. here is the LDAPsource:
private Iterator<SearchResult> getLdapResultsHelper(Search search, String searchValue, String[] attributeNames, boolean firstPageOnly ) { SubjectStatusResult subjectStatusResult = null; //if this is a search and not by id or identifier boolean subjectStatusQuery = StringUtils.equals("search", search.getSearchType()); if (subjectStatusQuery) { //see if we are doing status SubjectStatusProcessor subjectStatusProcessor = new SubjectStatusProcessor(searchValue, this.getSubjectStatusConfig()); subjectStatusResult = subjectStatusProcessor.processSearch(); //strip out status parts searchValue = subjectStatusResult.getStrippedQuery(); } ... further down ... String preStatusFilter = filter; if (subjectStatusQuery && !subjectStatusResult.isAll() && !StringUtils.isBlank(subjectStatusResult.getDatastoreFieldName())) { //validate the status value if (!subjectStatusResult.getDatastoreValue().matches("[a-zA-Z0-9_-]+")) { throw new RuntimeException("Invalid status value: " + subjectStatusResult.getDatastoreValue()); } //wrap the query in a status part filter = "(&" + filter + "(" + (subjectStatusResult.isEquals()?"":" ! ( ") + subjectStatusResult.getDatastoreFieldName() + "=" + subjectStatusResult.getDatastoreValue() + (subjectStatusResult.isEquals()?"":" ) ") + "))"; } if (!StringUtils.equals(preStatusFilter, filter)) { if (log.isDebugEnabled()) { log.debug("searchType: " + search.getSearchType() + ", preStatusFilter: " + preStatusFilter + ", filter: " + filter); } } else { if (log.isDebugEnabled()) { log.debug("searchType: " + search.getSearchType() + ", filter: " + filter); } }
sdf