Computer Science, asked by jayraj9151, 11 months ago

What is jndi authentication ? Explain with the help of an example?

Answers

Answered by Anonymous
0

In the JNDI, authentication information is specified in environment properties. When you create an initial context by using the InitialDirContext class (or its superclass or subclass), you supply a set of environment properties, some of which might contain authentication information.

Answered by qwcardiff
0

JNDI (Java Naming and Directory Interface) enables Java platform-based applications to access multiple naming and directory services.

In the JNDI, authentication information is specified in environment properties. When you create an initial context by using the InitialDirContext class (or its superclass or subclass), you supply a set of environment properties, some of which might contain authentication information.

Example -

// Set up the environment for creating the initial context

Hashtable<String, Object> env = new

Hashtable<String, Object>();

env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");

env.put(Context.PROVIDER_URL, "ldap://localhost:389/o=JNDITutorial");

// Authenticate as S. User and password "mysecret"

env.put(Context.SECURITY_AUTHENTICATION, "simple");

env.put(Context.SECURITY_PRINCIPAL,

"cn=S. User, ou=NewHires, o=JNDITutorial");

env.put(Context.SECURITY_CREDENTIALS, "mysecret");

// Create the initial context

DirContext ctx = new InitialDirContext(env);

// ... do something useful with ctx

#SPJ3

Similar questions