//Hashtable for environmental information
Hashtable env = new Hashtable(); //Specify which class to use for our JNDI provider
env.put(Context.INITIAL_CONTEXT_FACTORY, INITCTX); env.put(Context.SECURITY_AUTHENTICATION,MY_SECURITY_AUTHENTICATION);
env.put(Context.SECURITY_PRINCIPAL,MY_SECURITY_PRINCIPAL);
env.put(Context.SECURITY_CREDENTIALS,MY_SECURITY_CREDENTIALS);
// Specify host and port to use for directory service
env.put(Context.PROVIDER_URL, MY_HOST); //Get a reference to a directory context
DirContext ctx = new InitialDirContext(env); //specify the scope of the search
SearchControls constraints = new SearchControls();
constraints.setSearchScope(SearchControls.SUBTREE_SCOPE); //peform the actual search
//we give it a searchbase, a filter and a the constraints
//containing the scope of the search
NamingEnumeration results =
ctx.search(MY_SEARCHBASE,MY_FILTER_PRE+UID,constraints);
Hashtable env = new Hashtable(); //Specify which class to use for our JNDI provider
env.put(Context.INITIAL_CONTEXT_FACTORY, INITCTX); env.put(Context.SECURITY_AUTHENTICATION,MY_SECURITY_AUTHENTICATION);
env.put(Context.SECURITY_PRINCIPAL,MY_SECURITY_PRINCIPAL);
env.put(Context.SECURITY_CREDENTIALS,MY_SECURITY_CREDENTIALS);
// Specify host and port to use for directory service
env.put(Context.PROVIDER_URL, MY_HOST); //Get a reference to a directory context
DirContext ctx = new InitialDirContext(env); //specify the scope of the search
SearchControls constraints = new SearchControls();
constraints.setSearchScope(SearchControls.SUBTREE_SCOPE); //peform the actual search
//we give it a searchbase, a filter and a the constraints
//containing the scope of the search
NamingEnumeration results =
ctx.search(MY_SEARCHBASE,MY_FILTER_PRE+UID,constraints);
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货