it contains the practical programs in our college

源代码在线查看: digest.java

软件大小: 32796 K
上传用户: NJ_WK
关键词: practical contains programs college
下载地址: 免注册下载 普通下载 VIP

相关代码

				import javax.naming.*;				import javax.naming.directory.*;								import java.util.Hashtable;								/**				 * Demonstrates how to create an initial context to an LDAP server				 * using DIGEST-MD5 authentication.				 *				 * usage: java Digest				 */				class Digest {				    public static void main(String[] args) {									// Set up environment for creating initial context				        Hashtable env = new Hashtable(11);					env.put(Context.INITIAL_CONTEXT_FACTORY, 					    "com.sun.jndi.ldap.LdapCtxFactory");					env.put(Context.PROVIDER_URL, "ldap://localhost:389/o=JNDITutorial");									// Authenticate as C. User and password "mysecret"					env.put(Context.SECURITY_AUTHENTICATION, "DIGEST-MD5");									env.put(Context.SECURITY_PRINCIPAL, "dn:cn=C. User, ou=NewHires, o=JNDITutorial");					env.put(Context.SECURITY_CREDENTIALS, "mysecret");									env.put("com.sun.jndi.ldap.trace.ber", System.out);									try {					    // Create initial context					    DirContext ctx = new InitialDirContext(env);									    System.out.println(ctx.lookup("ou=NewHires"));									    // do something useful with ctx									    // Close the context when we're done					    ctx.close();					} catch (NamingException e) {					    e.printStackTrace();					}				    }				}							

相关资源