LISTSERV Maestro 8.1-4 Help

Forward >> << Back Table Of Contents

Target Group Definition: Database or LDAP directory access by LISTSERV

The Target Group Definition wizard lets you define a target group of the Database or LDAP directory access by LISTSERV type that can then be used in the recipients wizard to define the recipients of a job.

The wizard for a target group of the Database or LDAP directory access by LISTSERV type has multiple pages:
General, Source, Parameters, Input Layout, Input Preview, Recipients Details, and Summary.

The top row of the wizard displays links to these pages. The page that is currently open is marked with a highlighted background color. Depending on the choices made on some of the wizard pages, other pages may become disabled or may be shown in different versions. If a wizard page is disabled, then it means that the page is not necessary with the current choices and can safely be ignored.


Source Page: SQL Statement or LDAP Query

Define the method employed by LISTSERV to retrieve the recipients represented by this target group.

Enter the server alias used by LISTSERV to retrieve the recipients.

Decide if LISTSERV shall access an SQL database and execute the supplied statement or if LISTSERV shall access an LDAP directory and execute the supplied query.

Enter the SQL statement or LDAP query that shall be executed by LISTSERV to retrieve the recipients in the corresponding edit box. The query may be a fixed statement, or it may contain parameters that are later filled out by the end user when this target group is used in a recipients definition.

For SQL statements, see here for details on how to parameterize the SQL statement and for details about the meaning of the opening and closing tag input fields.
At the bottom of the screen, define which character the database uses to quote string literals (often this is a single quote character) in SQL statements. Also, define how that quote character is to be escaped if it occurs inside of a string literal's value. Escaping the quote character is often two single quote characters appearing next to each other.
For example: the quote character is "'", and the escaped quote character is "''". With these definitions, "O'Brian" as a quoted string literal would become "'O''Brian'".

For LDAP queries, see here for details on how to parameterize the query and for details about the meaning of the opening and closing tag input fields and about special issues regarding LDAP directory access.

How to parameterize a SQL statement, LDAP search filter or LISTSERV condition

Note: This explanation is valid for SQL statements, LDAP search filters and for LISTSERV conditions. All allow parameterization in a very similar manner. For the sake of simplicity however, the explanation below only mentions SQL statements (to avoid repeated occurrences of phrases like "SQL statement, LDAP search filter or LISTSERV condition").

To apply this explanation to a LISTSERV condition or LDAP search filter, simply read "condition" wherever the text says "SQL statement" or "statement" and modify the examples given to match a corresponding LISTSERV condition instead. The rules for LDAP queries are slightly different, see below.

A SQL statement for a target group can either be a "fixed" statement or a parameterized statement.

A fixed statement contains SQL code that is fixed, meaning that it will be used in the same form every time it is used with the target group. For example:

select * from recipients
Or more complex:
select email, name, gender from recipients where age >= 30 and age <= 39

Such a fixed statement will always yield the same results regardless of the circumstances of how the target group is used, as long as the actual database content does not change. A fixed statement is useful, but only under certain circumstances. The first example given here would simply select all entries from a certain table. If that is the required behavior, then a fixed statement is the correct statement type to use. The second example, on the other hand, selects only those recipients that are in their thirties (age >= 30 and <= 39). This is very limiting. Targeting a different age group would necessitate creating a new target group with a different SQL statement. In fact, with fixed statements, every different age group used would require its own target group and SQL statement. Setting up these fixed statements would involve a lot of work for the LISTSERV Maestro database administrator, as well as take away flexibility for the end users.

Using a parameterized statement can save time and effort as well as giving end users more flexibility in selecting recipients.

A parameterized statement contains placeholders in the SQL code that are replaced by the end user who uses the target group for the actual recipients definition. These placeholders are not "real" SQL code, but they are a sort of "meta" code. By using placeholders, parts of the SQL statement can be defined that are not yet "known" at the moment the SQL statement is entered into the system. These placeholders are then replaced with actual values before the statement is executed.

Using placeholders makes it possible to create a parameterized SQL statement that selects all recipients of a certain age range. The end user who employs the target group in a recipients definition is left with the decision of what age range to use when creating the recipients definition.

This example shows how the actual age range values are replaced with placeholders "{{from}}" and "{{to}}".

select email, name, gender from recipients where age >= {{from}} and age <= {{to}}

A placeholder is any string of characters that appears between special opening and closing tags. By default, the opening tag is "{{" and the closing tag is "}}". Everything surrounded by these two tags will be treated as parameter placeholders, and not as part of the actual SQL statement. If the default tag strings need to be used somewhere else in the statement without them being recognized as placeholder tags, different tag strings can be defined. This is done by entering new tags in the two edit boxes below the SQL statement input field.

These rules apply when using parameter placeholders:

How to parameterize a LISTSERV LDAP query

Similar to LISTSERV conditions and SQL statements, LISTSERV LDAP queries for a target group can either be "fixed" or parameterized.

A fixed query contains code that is fixed, meaning that it will be used in the same form every time it is used with the target group. For example:

BASE ou=Example Faculty,o=Example University,c=country
FILTER (objectclass=*)
Or more complex:
BASE ou=Example Faculty,o=Example University,c=country
FILTER (&(gender=male)(objectclass=person))
ATTRS mail givenName

Such a fixed query will always yield the same results regardless of the circumstances of how the target group is used, as long as the actual LDAP directory content does not change. A fixed query is useful, but only under certain circumstances. The first example given here would simply select all entries underneath the base DN "ou=Example Faculty,o=Example University,c=country". If that is the required behavior, then a fixed query is the correct query type to use. The second example, on the other hand, selects only men (in the example, this is accomplished by restricting the entries to those that have "gender=male" and "objectclass=person"). This is very limiting. Targeting a different gender would necessitate creating a new target group with a different query.

Using a parameterized query can save time and effort as well as giving end users more flexibility in selecting recipients.

Much like SQL statements and LISTSERV conditions, a parameterized LDAP query contains placeholders in the query code that are replaced by the end user who uses the target group for the actual recipients definition.

Using placeholders makes it possible to create a parameterized query that retrieves all entries with certain attributes (by having a parameter placeholder in the FILTER part of the query) or that retrieves all entries underneath a certain base DN (where the actual DN is parameterized, for example to start the search at configurable entry points of the LDAP directory). The end user who employs the target group in a recipients definition is left with the decision of what attributes or LDAP directory entry point to use when creating the recipients definition.

This example shows how the actual base DN value is augmented with a placeholder "{{faculty}}".

BASE ou={{faculty}},o=Example University,c=country
FILTER (objectclass=*)

A placeholder is any string of characters that appears between special opening and closing tags. By default, the opening tag is "{{" and the closing tag is "}}". Everything surrounded by these two tags will be treated as parameter placeholders, and not as part of the actual query. If the default tag strings need to be used somewhere else in the statement without them being recognized as placeholder tags, different tag strings can be defined. This is done by entering new tags in the two edit boxes below the query input field.

These rules apply when using parameter placeholders:

 

© 2002-2017 L-Soft Sweden AB. All rights reserved.