Class LDAPSearch
java.lang.Object
de.muehlencord.shared.network.ldap.LDAPSearch
Connection to LDAP server to search by different values
- Author:
- Joern Muehlencord (joern@muehlencord.de)
-
Constructor Summary
ConstructorsConstructorDescriptionLDAPSearch(String url, String searchBase, String username, String password) Creates a new instance of a LDAP search.LDAPSearch(String authentication, String url, String securityProtocol, String searchBase, String username, String password) Creates a new instance of a LDAP search. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()close the LDAP connectionbooleanemailExists(String email) Returns true, if the given email address can be found in the configured LDAP.Returns the search base of the LDAP connectionvoidinit()execute several init steps, connect to LDAPbooleanisMemberOfGroup(String email, String groupDn) Returns true, if the given email address is member of the given group, specified by the DNsearchContact(String searchField, String searchValue) searchContactWithEmail(String email) Searches a contact according to emailaddress in the address directory
-
Constructor Details
-
LDAPSearch
Creates a new instance of a LDAP search.Important:
If you want to use LDAPs - usually port 636 make sure you provide a trustkeystore in case your LDAP server does not use a certificate which can be trusted by the build in root certificates. (e.g. self signed certificates)To provide access to a trust center you can specify the following parameter to your application by providing the following parameter-Djavax.net.ssl.trustStore=/path/to/truststore.keystore
- Parameters:
url- the url of the LDAP server to connect to likeldap://ldapserver.your.domain:389searchBase- the search base to use - e.g.DC=domain,DC=tldusername- the username to connect withpassword- the password to connect with
-
LDAPSearch
public LDAPSearch(String authentication, String url, String securityProtocol, String searchBase, String username, String password) Creates a new instance of a LDAP search.Important:
If you want to use LDAPs - usually port 636 make sure you provide a trustkeystore in case your LDAP server does not use a certificate which can be trusted by the build in root certificates. (e.g. self signed certificates)To provide access to a trust center you can specify the following parameter to your application by providing the following parameter-Djavax.net.ssl.trustStore=/path/to/truststore.keystore
- Parameters:
authentication- the authentification type to use -e.g. "SIMPLE"url- the url of the ldap server to connect to likeldap://ldapserver.your.domain:389securityProtocol- the security protocol to use - e.g. SIMPLEsearchBase- the search base to use - e.g.DC=domain,DC=tldusername- the username to connect withpassword- the password to connect with
-
-
Method Details
-
init
execute several init steps, connect to LDAP- Throws:
LDAPException- if the connection cannot be established
-
close
close the LDAP connection- Throws:
LDAPException- if an error during closing appears.
-
getSearchBase
Returns the search base of the LDAP connection- Returns:
- the search base of the LDAP connection
-
searchContactWithEmail
Searches a contact according to emailaddress in the address directory- Parameters:
email- emailaddress to search for- Returns:
- LDAP contact or null if nothing could be found
- Throws:
LDAPException- when search fails
-
searchContact
- Throws:
LDAPException
-
emailExists
Returns true, if the given email address can be found in the configured LDAP.- Parameters:
email- the email address to search for- Returns:
- true, if the email address could be found; else false
- Throws:
LDAPException- if the search fails
-
isMemberOfGroup
Returns true, if the given email address is member of the given group, specified by the DN- Parameters:
email- the email to validategroupDn- the group search base - all members must be found as "member" in this group- Returns:
- true, if the given contact, specified by the email address is member of the specified group. Otherwise false is returned.
- Throws:
LDAPException- if the validation fails.
-