LFCS · Question #143
Which of the following arguments complete the command which will search for cn=ldapadmin OR ou=BR recursively in the directory? ldapsearch -LLL -h server -s sub -b "o=inc" "_______"
The correct answer is B. ( |(cn=ldapamin) (ou=BR) ). To perform an OR search in LDAP, the filter syntax requires the | operator to precede the conditions within parentheses.
Question
Options
- A( (cn=ldapamin)|(ou=BR) )
- B( |(cn=ldapamin) (ou=BR) )
- C( (cn=ldapamin) (ou=BR) )
- D( (cn=ldapamin) (ou=BR)| )
- E( (cn=ldapamin)||(ou=BR) )
How the community answered
(68 responses)- A4% (3)
- B91% (62)
- D1% (1)
- E3% (2)
Why each option
To perform an OR search in LDAP, the filter syntax requires the `|` operator to precede the conditions within parentheses.
This syntax `( (cn=ldapamin)|(ou=BR) )` incorrectly places the `|` operator between the conditions, which is not valid LDAP filter syntax for an OR.
The correct LDAP filter syntax for an OR operation places the `|` operator at the beginning of the parenthesized list of conditions, meaning `( |(condition1)(condition2) )` represents 'condition1 OR condition2'.
This syntax `( (cn=ldapamin) (ou=BR) )` represents an AND operation because the operator is implicitly AND when multiple conditions are listed without an explicit operator.
This syntax `( (cn=ldapamin) (ou=BR)| )` incorrectly places the `|` operator at the end of the conditions, which is not valid LDAP filter syntax for an OR.
This syntax `( (cn=ldapamin)||(ou=BR) )` uses `||`, which is not a valid LDAP filter operator for OR; the correct operator is a single `|`.
Concept tested: LDAP search filter OR syntax
Source: https://ldap.com/ldap-filters/
Topics
Community Discussion
No community discussion yet for this question.