Class LDAPSimpleAuth
java.lang.Object
netscape.ldap.beans.LDAPBasePropertySupport
netscape.ldap.beans.LDAPSimpleAuth
- All Implemented Interfaces:
Serializable
Invisible Bean that just authenticates a user with a Directory
Server and returns Y or N. It takes a host and port, and then either
a full distinguished name and password, an RDN and directory base, or
a cn value and directory base.
Optionally, a client can register as a PropertyChangeListener and will be notified when an authentication completes.
The Bean can be used from JavaScript, as in the following example where the parameters are taken from HTML text fields in an HTML form called "input":
Optionally, a client can register as a PropertyChangeListener and will be notified when an authentication completes.
The Bean can be used from JavaScript, as in the following example where the parameters are taken from HTML text fields in an HTML form called "input":
function checkAuthentication() { auth = new Packages.netscape.ldap.beans.LDAPSimpleAuth(); auth.setHost( document.input.host.value ); auth.setPort( parseInt(document.input.port.value) ); auth.setAuthDN( document.input.username.value ); auth.setAuthPassword( document.input.password.value ); result = auth.authenticate(); alert( "The response is: " + result ); }
- See Also:
-
Field Summary
Fields inherited from class LDAPBasePropertySupport
AMBIGUOUS_RESULTS, AUTHENTICATION_ERROR, CONNECT_ERROR, INVALID_PARAMETER, NO_SUCH_OBJECT, OK, PROPERTY_NOT_FOUNDModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final int -
Constructor Summary
ConstructorsConstructorDescriptionConstructor with no parametersLDAPSimpleAuth(String theHost, int thePort) Constructor with host and port initializersLDAPSimpleAuth(String theHost, int thePort, String dn, String password) Constructor with all required authentication parameters -
Method Summary
Modifier and TypeMethodDescriptionConnect to LDAP server using parameters specified in constructor and/or by setting properties and attempt to authenticate.voidauthenticate(String dn, String password) Connect to LDAP server using parameters specified in constructor and/or by setting properties and attempt to authenticate.static voidThe main body if we run it as stand-alone application.Methods inherited from class LDAPBasePropertySupport
addPropertyChangeListener, connect, convertToString, firePropertyChange, getAuthDN, getAuthPassword, getBase, getDebug, getErrorCode, getFilter, getHost, getPort, getScope, getUserID, getUserName, printDebug, removePropertyChangeListener, setAuthDN, setAuthPassword, setBase, setDebug, setDefaultReferralCredentials, setErrorCode, setFilter, setHost, setPort, setScope, setUserID, setUserNameModifier and TypeMethodDescriptionvoidAdd a client to be notified when an authentication result is inprotected voidconnect(LDAPConnection conn, String host, int port) Sets up basic connection privileges for Communicator if necessary, and connectsconvertToString(String[] aResult) Utility method to convert an array of Strings to a single String with line feeds between elements.voidfirePropertyChange(String propName, Object oldValue, Object newValue) Support for bound property notificationReturns the DN to authenticate as; null or empty for anonymous.Returns the password for the DN to authenticate asgetBase()Returns the directory base to search at.booleangetDebug()Returns true if debug output is onintReturns the latest error codeReturns the search filtergetHost()Returns the host to search at.intgetPort()Returns the port to search at.intgetScope()Get the current search scopeReturn the user ID.Returns the user nameprotected voidprintDebug(String s) voidRemove a client which had requested notification on authenticationvoidSets the DN to authenticate as; null or empty for anonymous.voidsetAuthPassword(String authPassword) Sets the password for the DN to authenticate asvoidSets the starting basevoidsetDebug(boolean on) Turns debug output on or offprotected voidvoidsetErrorCode(int code) Sets an error code for retrieval by a clientvoidSets the search filtervoidSets host string.voidsetPort(int thePort) Sets port number.voidsetScope(int scope) Set the search scope using an integervoidSet the user ID.voidsetUserName(String name) Set the user name.
-
Constructor Details
-
LDAPSimpleAuth
public LDAPSimpleAuth()Constructor with no parameters -
LDAPSimpleAuth
Constructor with host and port initializers- Parameters:
theHost- host stringthePort- port number
-
LDAPSimpleAuth
-
-
Method Details
-
authenticate
Connect to LDAP server using parameters specified in constructor and/or by setting properties and attempt to authenticate.- Returns:
- "Y" on successful authentication, "N" otherwise
-
authenticate
Connect to LDAP server using parameters specified in constructor and/or by setting properties and attempt to authenticate.- Parameters:
dn- fully qualified distinguished name to authenticatepassword- password for authenticating the dn- Returns:
- "Y" on successful authentication, "N" otherwise
-
authenticate
-
main
The main body if we run it as stand-alone application.- Parameters:
args- list of arguments
-