Softerra LDAP Administrator HelpShow AllHide All

LDAP-SQL Operators

An operator is a symbol specifying an action that is performed on one or several expressions. The following operators are defined in LDAP-SQL:

Arithmetic Operators

OperatorDescription
+ Addition

Syntax
expression + expression
- Subtraction

Syntax
expression - expression
* Multiplication

Syntax
expression * expression
/ Division

Syntax
expression / expression

Attributes

expression - any correct expression of any number data type.

Examples

Prolonging the value of the accountExpires attribute for 5 days:

UPDATE "CN=John Doe,DC=company" 
SET $accountExpires = $accountExpires + interval '5 days'
SCOPE BASE

Increase the value of the minPwdLength attribute in 3 times:

UPDATE "DC=company,DC=com" 
SET $minPwdLength = $minPwdLength * 3

Logical Operators

Logical operators test for the truth of some condition. Logical operators, like comparison operators, return a Boolean data type with a value of TRUE or FALSE.

OperatorDescription
AND Combines two logical expressions and returns TRUE, if both expressions are TRUE. Otherwise, FALSE is returned.

Syntax
boolean_expression AND boolean_expression
OR TRUE, if one of boolean expressions is TRUE. Otherwise, returns FALSE.

Syntax
boolean_expression AND boolean_expression
NOT Negates a boolean expression

Syntax
NOT boolean_expression
EXISTS TRUE, if the requested attribute is defined.

Syntax
EXISTS attribute_name
IS [NOT] NULL TRUE is returned, if the value is [not] equal to NULL. Otherwise, returns FALSE.

Syntax
attribute_name IS [NOT] NULL

Attributes

boolean_expression - any acceptable boolean expression, the result of which is TRUE or FALSE.

attribute_name - name of the LDAP attribute.

Examples

Search for all users with mail attribute.

SELECT * FROM "OU=Managers,DC=company" 
WHERE $objectClass='user' AND $objectCategory='Person'
    AND EXISTS $mail

Find all users and computers.

SELECT * FROM "OU=Managers,DC=company" 
WHERE $objectClass='user' AND $objectCategory='Person'
    OR $objectClass='computer'

Search for all objects of class room with the roomNumber attribute specified.

SELECT * FROM "OU=Managers,DC=company" 
WHERE $objectClass='room' AND $roomNumber IS NOT NULL 

Comparison Operators

With the help of comparison operators, you can compare two values. LDAP-SQL comparison operators are listed in the table below:

OperatorDescription
= Is equal
> Is greater
< Is less
>= Is greater or equal
<= Is less or equal
!= Not equal
<> Not equal

Syntax

expression operator expression

Attributes

expression - any acceptable expression. If expressions refer to different data types, data type of one expression must be implicitly available for converting into the data type of another expression.

operator - any comparison operator.

Examples

Search for all objects of class computer created from 2009-02-03 till 2010-11-25.

SELECT * FROM "DC=company,DC=com" 
WHERE $objectClass='computer 'AND 
    $whenCreated >= '2009-02-03' AND $whenCreated <= '2010-11-25'

Search for all users whose givenName attribute is set to Jason.

SELECT * FROM "OU=Users,DC=company" 
WHERE $objectClass='user' AND $objectCategory='Person'
    AND $givenName = 'Jason' 

Assignment Operator

The equality sign (=) is the only assignment operator in the LDAP-SQL language and is used in the UPDATE statement only to assign attribute values.

Examples

Update accountExpires attribute of the user.

UPDATE " CN=John Doe,DC=Company"  
SET $accountExpires = '2010-10-23'
SCOPE BASE

String Join Operator

The double-pipe symbol (||) is a string join operator. All other operations with strings are made with the help of string functions.

Examples

Joining three strings and assigning them to the description LDAP attribute.

UPDATE "CN=John Doe,DC=company" 
SET $description= 'John Doe' || ' - ' || 'Sales department'

Joining two LDAP attributes and assigning them to the description attribute.

UPDATE "CN=John Doe,DC=company" 
SET $description= $givenName || $mail