List of usage examples for javax.naming Context PROVIDER_URL
String PROVIDER_URL
To view the source code for javax.naming Context PROVIDER_URL.
Click Source Link
From source file:SearchControlsExample.java
public static void main(String[] argc) throws Exception { 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"); DirContext dctx = new InitialDirContext(env); String filter = "(&(cn=S*)(account>1005))"; String[] attrIDs = { "cn", "email" }; SearchControls sc = new SearchControls(); sc.setReturningAttributes(attrIDs);/*from w w w.java 2s. c om*/ NamingEnumeration result = dctx.search("ou=People", filter, sc); while (result.hasMore()) { SearchResult sr = (SearchResult) result.next(); System.out.println("Result = " + sr.getName()); } }
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); DirContext ctx = new InitialDirContext(env); String[] attrIDs = { "sn", "number", "value", "mail" }; Attributes answer = ctx.getAttributes("cn=yourName, ou=People", attrIDs); NamingEnumeration e = answer.getAll(); while (e.hasMore()) { Attribute attr = (Attribute) e.next(); System.out.println(attr.getID()); }/*from w w w.j a v a 2s .c o m*/ }
From source file:Main.java
public static void main(String[] argv) throws Exception { Hashtable<String, String> env = new Hashtable<String, String>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, "YourURL"); env.put(Context.SECURITY_AUTHENTICATION, "simple"); env.put(Context.SECURITY_PRINCIPAL, "userDN"); env.put(Context.SECURITY_CREDENTIALS, "secret"); EventContext ctx = (EventContext) (new InitialContext(env).lookup("ou=People")); NamingListener listener = new SampleNCListener(); ctx.addNamingListener("cn=John", EventContext.ONELEVEL_SCOPE, listener); }
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"); LdapContext ctx = new InitialLdapContext(env, null); NamingEnumeration answer = ctx.search("ou=People", "(cn=*)", null); System.out.println(ctx.getResponseControls()); while (answer.hasMore()) { SearchResult si = (SearchResult) answer.next(); if (si instanceof HasControls) { System.out.println(((HasControls) si).getControls()); }//from w w w . j a v a 2 s.c o m } System.out.println(ctx.getResponseControls()); }
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"); Control[] connectCtls = new Control[] { null }; LdapContext ctx = new InitialLdapContext(env, null); Control[] ctxCtls = new Control[] { new SortControl(new String[] { "cn" }, Control.CRITICAL) }; ctx.setRequestControls(ctxCtls);/*w w w . ja va 2 s . com*/ NamingEnumeration answer = ctx.list(""); while (answer.hasMore()) { NameClassPair item = (NameClassPair) answer.next(); } }
From source file:Delete.java
public static void main(String[] args) throws Exception { String initalContextString = "/tmp/marketing/reports"; if (args.length < 1) { System.out.println("Usage: java Delete filename"); System.exit(-1);/* w w w . jav a2 s. com*/ } System.out.println("This program assumes the context is " + initalContextString); Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.fscontext.RefFSContextFactory"); env.put(Context.PROVIDER_URL, "file:" + initalContextString); Context initCtx = new InitialContext(env); System.out.println("Attempting to unbind " + args[0]); initCtx.unbind(args[0]); System.out.println("Done."); }
From source file:TestDSBind.java
public static void main(String args[]) throws SQLException, NamingException { // For this to work you will need to create the // directories /JNDI/JDBC on your file system first Context ctx = null;/*from ww w . j av a2s. co m*/ try { Properties prop = new Properties(); prop.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.fscontext.RefFSContextFactory"); prop.setProperty(Context.PROVIDER_URL, "file:/JNDI/JDBC"); ctx = new InitialContext(prop); } catch (NamingException ne) { System.err.println(ne.getMessage()); } OracleDataSource ds = new OracleDataSource(); ds.setDriverType("thin"); ds.setServerName("dssw2k01"); ds.setPortNumber(1521); ds.setDatabaseName("orcl"); ds.setUser("scott"); ds.setPassword("tiger"); ctx.bind("joe", ds); }
From source file:AttributeExample.java
public static void main(String[] argc) throws Exception { 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"); DirContext dctx = new InitialDirContext(env); Attributes attrs = new BasicAttributes(true); attrs.put(new BasicAttribute("email")); attrs.put(new BasicAttribute("website", "www.pri.com")); NamingEnumeration result = dctx.search("ou=People", attrs); while (result.hasMore()) { SearchResult sr = (SearchResult) result.next(); System.out.println("Result = " + sr.getName()); Attributes srchAttrs = sr.getAttributes(); NamingEnumeration attributes = srchAttrs.getAll(); while (attributes.hasMore()) { Attribute attr = (Attribute) attributes.next(); System.out.println("Attribute: " + attr.getID()); NamingEnumeration values = attr.getAll(); while (values.hasMore()) { Object value = values.next(); System.out.println("Value = " + value); }/*from www . ja v a 2 s . c o m*/ } } }
From source file:Main.java
public static void main(String args[]) throws Exception { Hashtable<String, String> env = new Hashtable<String, String>(); env.put(Context.INITIAL_CONTEXT_FACTORY, INITCTX); env.put(Context.PROVIDER_URL, MY_HOST); env.put(Context.SECURITY_AUTHENTICATION, "simple"); env.put(Context.SECURITY_PRINCIPAL, MGR_DN); env.put(Context.SECURITY_CREDENTIALS, MGR_PW); DirContext ctx = new InitialDirContext(env); Person p = new Person(); ctx.bind("uid=mewilcox, ou=People, o=airius.com", p); }
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"); EventDirContext ctx = (EventDirContext) (new InitialContext(env).lookup("ou=People")); NamingListener listener = new SampleObjListener(); SearchControls ctls = new SearchControls(); ctls.setSearchScope(SearchControls.SUBTREE_SCOPE); String filter = "(mail=*)"; ctx.addNamingListener("cn=YourName", filter, ctls, listener); }