Class LdapCatalog
-
Method Summary
Modifier and TypeMethodDescriptionstatic LdapCatalogOpens a connection bound anonymously, without sending a name or a password.voidclose()Searches request for Ldap catalog.searchEntries(String dn, String filter, ScopeType scope, String... attributes) Searches the catalog and returns the matched entries, each with the full distinguished name the directory reports for it and the requested attributes.static LdapCatalogsimpleBind(String url, String user, String password) Opens a connection bound asuserwith a simple bind.
-
Method Details
-
anonymous
Opens a connection bound anonymously, without sending a name or a password.Anonymous is a deliberate choice of the caller, never a fallback:
simpleBind(java.lang.String, java.lang.String, java.lang.String)refuses to bind with an incomplete identity rather than silently ending up here.- Parameters:
url- Ldap server url.- Throws:
NamingException- in case when failed to connect to Ldap catalog.
-
simpleBind
public static LdapCatalog simpleBind(String url, String user, String password) throws NamingException Opens a connection bound asuserwith a simple bind.Both the name and the password are required. Per RFC 4513 5.1.2 a simple bind with a populated name and an empty password is an "unauthenticated bind", and a bind with an empty name is anonymous; most directory servers accept both and return success, so sending either would bind weaker than the caller asked for while looking like a successful authentication.
- Parameters:
url- Ldap server url.user- Distinguished name to bind as.password- Password ofuser.- Throws:
NamingException- in case when failed to connect to Ldap catalog.LdapAuthenticationException- whenuserorpasswordisnullor blank.
-
search
public List<Map<String,List<String>>> search(String dn, String filter, ScopeType scope, String... attributes) throws NamingException Searches request for Ldap catalog.- Parameters:
dn- Distinguished name.filter- Search filter.scope- Search scope type.attributes- Searchable attributes.- Returns:
- List of founded entries with attributes map.
- Throws:
NamingException- in case when search request failed.
-
searchEntries
public List<LdapEntry> searchEntries(String dn, String filter, ScopeType scope, String... attributes) throws NamingException Searches the catalog and returns the matched entries, each with the full distinguished name the directory reports for it and the requested attributes.Unlike
search(java.lang.String, java.lang.String, org.gridgain.internal.security.ldap.ScopeType, java.lang.String...), the distinguished name is kept: a search matches under case-insensitive matching rules, so the caller needs the directory's own spelling of an entry rather than the values it searched with. Also unlikesearch(java.lang.String, java.lang.String, org.gridgain.internal.security.ldap.ScopeType, java.lang.String...), passing no attribute names requests none rather than all of them, so a caller that wants only distinguished names does not pay for the rest of the entry.- Parameters:
dn- Base distinguished name to search under.filter- Search filter.scope- Search scope type.attributes- Names of the attributes to return; none to return only the distinguished names.- Returns:
- Matched entries.
- Throws:
NamingException- in case when search request failed.
-
close
- Throws:
NamingException
-