Custom JSP taglib. Two body tags check authentication against the given LDAP server. Tag isAuthenticated executes own body if user is authenticated and tag isNotAuthenticated executes own body if user is not authenticated. For example:
<%@ taglib uri="taglib.tld" prefix="if" %> <if:isAuthenticated user="uid=guest" password="12345" url="ldap://localhost:389" factory="com.sun.jndi.ldap.LdapCtxFactory"> ... I am a guest ... </if:isAuthenticated> <if:isNotAuthenticated user="cn=test,o=company" password="my_secret_word" url="ldap://localhost:636" level="simple" factory="com.sun.jndi.ldap.LdapCtxFactory" protocol="ssl"> ... Sorry, you are not allowed ... </if:isNotAuthenticated> For the authenticated users tag isAuthenticated can create a nested page scope variable with the directory
context. You can request the attributes for example:
<%@ taglib uri="taglib.tld" prefix="if" %> <if:isAuthenticated user="uid=guest" password="12345" id="dir" url="ldap://localhost:389" factory="com.sun.jndi.ldap.LdapCtxFactory"> ... <% javax.naming.directory.Attributes attrs = dir.getAttributes("cn = Ted Geisel, ou=People"); Object sn = attrs.get("sn").get(); %> ... </if:isAuthenticated> Tags are: isAuthenticated Executes own body if user is authenticated against the given LDAP. Parameters are: 1) factory context factory class. E.g.: com.sun.jndi.ldap.LdapCtxFactory
isNotAuthenticated Executes own body if user is not authenticated against the given LDAP. Parameters are: 1) factory context factory class. E.g.: com.sun.jndi.ldap.LdapCtxFactory
for downloading: Library: ldaptag.jar Description: taglib.tld See also Coldtags suite - the largest collection of custom JSP tags. |
Also in Coldtags:
|