List of usage examples for java.util Hashtable put
public synchronized V put(K key, V value)
From source file:Main.java
public static void main(String[] argv) throws Exception { String url = "ldap://localhost/o=JNDITutorial"; Hashtable<String, String> env = new Hashtable<String, String>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, url); env.put(Context.SECURITY_AUTHENTICATION, "simple"); env.put(Context.SECURITY_PRINCIPAL, "userDN"); env.put(Context.SECURITY_CREDENTIALS, "secret"); DirContext ctx = new InitialDirContext(env); }
From source file:Main.java
public static void main(String[] s) { Hashtable<String, String> table = new Hashtable<String, String>(); table.put("key1", "value1"); table.put("key2", "value2"); table.put("key3", "value3"); Map m = Collections.unmodifiableMap(table); m.put("key3", "value3"); System.out.println(m);//from ww w. j a v a2 s .c om }
From source file:Main.java
public static void main(String args[]) { Hashtable<String, String> hash = new Hashtable<String, String>(); hash.put("1", "one"); hash.put("2", "two"); hash.put("3", "three"); Enumeration keys = hash.keys(); while (keys.hasMoreElements()) { Object key = keys.nextElement(); Object value = hash.get(key); System.out.println(key + " : " + value); }//from w w w . ja va2 s .co m }
From source file:Main.java
public static void main(String[] s) { Hashtable<String, String> table = new Hashtable<String, String>(); table.put("key1", "value1"); table.put("key2", "value2"); table.put("key3", "value3"); Enumeration e = table.elements(); while (e.hasMoreElements()) { String key = (String) e.nextElement(); System.out.println(key + " : " + table.get(key)); }// w ww . j a v a 2 s . co m System.out.println(table.values()); }
From source file:Main.java
public static void main(String[] argv) throws Exception { String url = "ldap://localhost/o=JNDITutorial"; Hashtable<String, String> env = new Hashtable<String, String>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, url); env.put(Context.SECURITY_AUTHENTICATION, "simple"); env.put(Context.SECURITY_PRINCIPAL, "userDN"); env.put(Context.SECURITY_CREDENTIALS, "secret"); // Create connection controls to use Control[] connectCtls = new Control[] { null }; LdapContext ctx = new InitialLdapContext(env, connectCtls); }
From source file:Main.java
public static void main(String[] argv) throws Exception { String url = "iiop://localhost/"; Hashtable<String, String> env = new Hashtable<String, String>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory"); env.put(Context.PROVIDER_URL, url); Context ctx = new InitialContext(env); // Create a subcontext. Context childCtx = ctx.createSubcontext("child"); // Destroy the subcontext. ctx.destroySubcontext("child"); }
From source file:SearchScopeExample.java
public static void main(String[] argc) { Hashtable env = new Hashtable(11); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, "ldap://MyHost/o=JNDIExample"); try {/*from w ww .j av a 2 s.c om*/ DirContext dctx = new InitialDirContext(env); String filter = "(&(cn=S*)(account>1000))"; String[] attrIDs = { "cn", "email" }; SearchControls sc = new SearchControls(); sc.setReturningAttributes(attrIDs); sc.setSearchScope(SearchControls.SUBTREE_SCOPE); NamingEnumeration result = dctx.search("ou=People", filter, sc); while (result.hasMore()) { SearchResult sr = (SearchResult) result.next(); System.out.println("Result = " + sr.getName()); } } catch (NamingException e) { System.out.println(e); } }
From source file:Main.java
public static void main(String[] s) { Hashtable<String, String> table = new Hashtable<String, String>(); table.put("key1", "value1"); table.put("key2", "value2"); table.put("key3", "value3"); Hashtable<String, String> table2 = new Hashtable<String, String>(); table2.put("key4", "value4"); table2.put("key5", "value5"); table2.put("key6", "value6"); table2.putAll(table);/*from w w w. j ava 2 s .co m*/ System.out.println(table2); }
From source file:Main.java
public static void main(String[] argv) throws Exception { String url = "iiop://localhost/"; Hashtable<String, String> env = new Hashtable<String, String>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory"); env.put(Context.PROVIDER_URL, url); Context ctx = new InitialContext(env); NameParser parser = ctx.getNameParser(""); Name dn = parser.parse("cn=John, ou=People, o=JNDITutorial"); dn.remove(1);/*from ww w . ja v a 2s. c o m*/ dn.add(0, "c=us"); dn.add("cn=fs"); }
From source file:Main.java
public static void main(String[] argv) throws Exception { String url = "iiop://localhost/"; Hashtable<String, String> env = new Hashtable<String, String>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory"); env.put(Context.PROVIDER_URL, url); Context ctx = new InitialContext(env); NamingEnumeration e = ctx.list("child"); while (e.hasMore()) { NameClassPair entry = (NameClassPair) e.next(); System.out.println(entry.getName()); }//from w w w . ja v a 2s . c o m }