LDAP filter conditions and search for specified attributes

Source: Internet
Author: User
Tags ldap ldap filter
Public ldapsearchresults searchldapsearchresults (string basedn) {ldapsearchconstraintsobject (); try {If (ldapconf. log. equals ("yes") {log.info ("start to get data .. ");} ldaprsults = LC. search (basedn, ldapconnection. scope_sub, "(& (objectclass = person )(! (Useraccountcontrol = 514) (Mail = *) ", new string [] {" telephonenumber "," cn "," displayname "," company "," mailnickname ", "Mail", "mobile", "Sn", "department", "userprincipalname", "streetaddress"}, false, LSC);} catch (ldapexception E) {log.info ("failed to get data .. "); log.info (e); E. printstacktrace ();} return ldaprsults ;}

&

And (all items in the list must be true)

|

Or (at least one in the list must be true)

!

Non (the reverse item cannot be true)

=

Equal (matching rules based on attributes)

~ =

Approximate equals (matching rules based on attributes)

> =

Greater than (matching rules based on attributes)

<=

Less than (matching rules based on attributes)

= *

Yes (this attribute must exist in the entry, but the value is not limited)

*

Wildcard (indicating that this location can contain one or more characters), used when specifying the attribute value

\

Escape Character (escape when "*", "(", ")" is encountered)

 

 

Excerpt Conditions

  • The following filter searches for entries that contain one or more manager attribute values. This is also called an existing search: Manager = *

  • The following filter searches for entries that contain the generic name Ray kultgen. This is also called equivalent search: Cn = Ray kultgen

  • The following filters return all entries that do not contain the generic name Ray kultgen :(! (CN = Ray kultgen ))

  • All entries returned by the following filter contain the description attribute of the sub-string X.500: Description = * X.500 *

  • The following filter returns all entries whose organizational unit is marketing and the description field does not contain the sub-string X.500: (& (ou = Marketing )(! (Description = * X.500 *)))

  • The following filter returns all entries whose organizational unit is marketing and whose manager is Julie fulmer or Cindy zwaska: (& (ou = Marketing) (| (Manager = Cn = Julie fulmer, ou = marketing, dc = siroe, Dc = com) (Manager = Cn = Cindy zwaska, ou = marketing, Dc = siroe, Dc = com )))

  • The following filters return all entries that do not represent a person :(! (Objectclass = person ))

  • The following filter returns all entries that do not represent a person and have a common name similar to printer3b :(&(! (Objectclass = person) (CN ~ = Printer3b ))

LDAP filter conditions and search for specified attributes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.