public class LDAP extends Object
Utility class that offers useful functions for standard LDAP directories.
Intended for use in the lsc.properties configuration file via the JavaScript Rhino interpreter.
Rationale: the methods in this class have been thought out for repeated calls during a synchronization task, when each method may be called as many times as objects are synchronized. Thus, we attempt to optimize resource utilization.
Modifier and Type | Method and Description |
---|---|
static boolean |
canBind(String url,
String dnToCheck,
String passwordToCheck)
Connects to a LDAP server anonymously and tries to rebind with the
provided DN and password to check.
|
static boolean |
canBind(String url,
String bindDn,
String bindPassword,
String dnToCheck,
String passwordToCheck)
Connects to a LDAP server using a specific DN and password, then tries to
rebind with the provided DN and password to check.
|
static boolean |
canBindSearchRebind(String url,
String passwordToCheck)
Connects to a LDAP server anonymously, then performs a search to find a
DN, then tries to rebind with the provided DN and password to check
authentication.
|
static boolean |
canBindSearchRebind(String url,
String bindDn,
String bindPassword,
String passwordToCheck)
Connects to a LDAP server using a specific DN and password, then performs
a search to find a DN, then tries to rebind with the provided DN and
password to check authentication.
|
public static boolean canBind(String url, String dnToCheck, String passwordToCheck) throws NamingException
url
- URL of the LDAP server to connect to, e.g.
"ldap://ldap.example.com/". If this URL starts with "ldaps" a
secure connection will be used.dnToCheck
- Distinguished Name (DN) to check the bind with.passwordToCheck
- Password to check the bind with.NamingException
- any exceptions that occur during connection, other than bind
failurespublic static boolean canBind(String url, String bindDn, String bindPassword, String dnToCheck, String passwordToCheck) throws NamingException
url
- URL of the LDAP server to connect to, e.g.
"ldap://ldap.example.com/". If this URL starts with "ldaps" a
secure connection will be used.bindDn
- DN to bind to the server with. If null, binds anonymously.bindPassword
- Password to bind to the server with.dnToCheck
- Distinguished Name (DN) to check the bind with.passwordToCheck
- Password to check the bind with.NamingException
- any exceptions that occur during connection, other than bind
failurespublic static boolean canBindSearchRebind(String url, String passwordToCheck) throws NamingException, org.apache.directory.api.ldap.model.exception.LdapURLEncodingException
url
- URL of the LDAP server to connect to and search parameters,
e.g.
"ldap://ldap.example.com/dc=example,dc=com??sub?(uid=nportman)"
. If this URL starts with "ldaps" a secure connection will be
used. This URL must include the search filter, and may include
the search scope, which defaults to "sub".passwordToCheck
- Password to check the bind with.NamingException
- any exceptions that occur during connection, other than bind
failures and no search resultsorg.apache.directory.api.ldap.model.exception.LdapURLEncodingException
MalformedURLException
- If the search URL is malformed.public static boolean canBindSearchRebind(String url, String bindDn, String bindPassword, String passwordToCheck) throws NamingException, org.apache.directory.api.ldap.model.exception.LdapURLEncodingException
url
- URL of the LDAP server to connect to and search parameters,
e.g.
"ldap://ldap.example.com/dc=example,dc=com??sub?(uid=nportman)"
. If this URL starts with "ldaps" a secure connection will be
used. This URL must include the search filter, and may include
the search scope, which defaults to "sub".bindDn
- DN to bind to the server with. If null, binds anonymously.bindPassword
- Password to bind to the server with.passwordToCheck
- Password to check the bind with.NamingException
- any exceptions that occur during connection, other than bind
failures and no search resultsorg.apache.directory.api.ldap.model.exception.LdapURLEncodingException
MalformedURLException
- If the search URL is malformed.Copyright © 2005-2024 LSC project. All Rights Reserved.