YouTube Icon

Interview Questions.

Top 25 Java Naming And Directory Interface (JNDI) Interview Questions - Jul 26, 2022

fluid

Top 25 Java Naming And Directory Interface (JNDI) Interview Questions

Q1. Uses Of Ldap?

A massive no. Of machines will have a not unusual listing of login users.

Reading accesses and responsiveness is rapid.

LDAP can be used to cluster when failover takes place.

Q2. How Does Jndi Relate To Netscape's Java Ldap Api?

Netscape's API is LDAP-precise. It is used for low-stage get admission to to LDAP directories. It exposes information about the protocol that packages generally do no longer need to understand. 

Q3. Where Is Jndi Being Used In The Java Platform?

HotJava Views 1.1 is using JNDI to get right of entry to LDAP.

Enterprise APIs consisting of 

Enterprise JavaBe

Java Message Service

JDBC 2.0

make use of JNDI to for their naming and listing wishes.

RMI over IIOP packages can use JNDI to get admission to the CORBA (COS) naming carrier.

Q4. What Is A Naming Service?

Naming offerings map gadgets with names. It maps a connection with an item with the aid of a consumer pleasant name. For instance a machine maps its ip deal with. The affiliation of an object with a call is referred to as ‘binding’. Examples : Domain Naming Service, File systems.

Q5. What Is A Jndi Initialcontext ?

All naming operations are relative to a context. The InitalContext implements the Context interface and affords an access factor for the resolution of names.

Q6. So Where Does Jndi Fit Into This Ldap ?

JNDI affords a general API for interacting with naming and directory offerings using a service company interface (SPI), which is analogous to JDBC motive force. To connect to an LDAP server, you need to acquire a reference to an object that implements the DirContext. In most applications, this is accomplished with the aid of the use of an InitialDirContext item that takes a Hashtable as an argument: 

Hashtable env = new Hashtable();

env.Put(Context.INITIAL_CONTEXT_FACTORY, "com.Solar.Jndi.Ldap.LdapCtxFactory");

env.Placed(Context.PROVIDER_URL, "ldap://localhost:387");

env.Positioned(Context.SECURITY_AUTHENTICATION, "easy");

env.Placed(Context.SECURITY_PRINCIPAL, "cn=Directory Manager");

env.Positioned(Context.SECURITY_CREDENTIALS, "myPassword");

DirContext ctx = new InitialDirContext(env); 

Q7. Can You Explain Why We Need Jndi If Communication To Systems Via Ldap Is Possible?

JNDI is also used to lookup resources like a database or a message queue. With JNDI you get a uniform way to get entry to listing services.

Q8. Explain The Difference Between The Look Up Of "java:comp/env/ejb/mybean" And "ejb/mybean" ?

Java:comp/env/ejb/MyBean: This is a logical reference, if you want to be used for your code.

Ejb/MyBean: This is a bodily reference wherein an object could be mapped to in a JNDI tree.

The logical reference (or alias) java:comp/env/ejb/MyBean is the endorsed technique due to the fact you cannot assure that the physical JNDI place ejb/MyBean you specify to your code can be available. Your code will smash if the physical vicinity is modified. The deployer will no longer be capable of alter your code. Logical references clear up this hassle with the aid of binding the logical name to the physical name within the utility server. The logical names might be declared inside the deployment descriptors (web.Xml and/or ejb-jar.Xml) as follows and these may be mapped to physical JNDI places within the utility server unique deployment descriptors. To appearance up a JDBC aid from either Web (net.Xml) or EJB (ejb-jar.Xml) tier, the deployment descriptor have to have the subsequent access: 

<resource-ref>

<description>The DataSource</description>

<res-ref-name>jdbc/MyDataSource</res-ref-name>

<res-type>javax.Sq..DataSource</res-type>

<res-auth>Container</res-auth>

</resource-ref> 

To use it: 

Context ctx = new InitialContext();

Object ref = ctx.Research(java:comp/env/jdbc/MyDataSource); 

To appearance up EJBs from every other EJB or a Web module, the deployment descriptor must have the following entry: 

<ejb-ref>

<description>myBean</description>

<ejb-ref-name>ejb/MyBean</ejb-ref-name>

<ejb-ref-type>Entity</ejb-ref-type>

<ejb-link>Region</ejb-link>

<home>com.MyBeanHome</home>

<remote>com.MyBean</remote>

</ejb-ref> 

To use it: 

Context ctx = new InitialContext();

Object ref = ctx.Lookup(java:comp/env/ejb/MyBean); 

Q9. How Do We Use Ldap To Work With A Directory Service?

At the time of creation of the databases, the existing LDAP will get hold of the database server example and the database records is furnished to the LDAP listing after the creation of the databases.

The catalog information for the server can be retrieved for the directory of LDAP, at the time of the patron’s connection to the database.

The catalogue information need not be saved regionally on each system for the clients.

The LDAP directory might be searched by way of the client packages for the wished data with a view to hook up with the database.

Q10. Explain The Importance Of Jndi?

To centralize the facts garage the establishments uses LDAP. The facts is of person names, passwords, e mail addresses, printers, willpower of database access. Multiple database control is decreased by centralizing the facts.

Q11. What Is Xfn And How Does This Relate To Jndi?

XFN is X/Open Federated Naming, a C-primarily based trendy for accessing a couple of, likely federated naming and listing offerings.

A programmer acquainted with XFN will find it clean to use JNDI. 

Q12. Who Will Provide Implementations Of Jndi?

At the time of this writing, IBM, Novell, Sun, and WebLogic have produced provider carriers for JNDI.

Q13. How Does Jndi Relate To Omg's Corba Standards For Naming?

A Java CORBA application can use JNDI to get entry to to the CORBA (COS) name provider, in addition to different naming and directory services.

It gives the software one interface for getting access to these kinds of naming and listing offerings. 

Using JNDI additionally paves the way for Java CORBA applications to use a dispensed organisation-level carrier like LDAP to save object references.

Q14. How Does Jndi Relate To Ldap?

JNDI offers an notable item-orientated abstraction of listing and naming. 

Developers the use of JNDI can produce queries that use LDAP or different get right of entry to protocols to retrieve outcomes; however, they may be now not restrained to LDAP nor do they need to increase their packages stressed to LDAP. JNDI helps the key talents in LDAP v3.

Q15. Tell Me What Do You Know About Ldap?

Lightweight Directory Access Protocol Developed by the University of Michigan.

It is a protocol for locating businesses, people, and other assets along with files and devices in a network, whether or not on the public Internet or on a company intranet.

Q16. What Is Jndi ? And What Are The Typical Uses Within A J2ee Application ?

JNDI stands for Java Naming and Directory Interface. It affords a common interface to LDAP (Lightweight Directory Access Protocol) and other directory services like NDS, DNS (Domain Name System) and so forth. It offers a me for an software to locate additives that exist in a name area in line with certain attributes.

A J2EE application thing makes use of JNDI interfaces to appearance up and reference system-supplied and consumer-defined objects in a element surroundings. JNDI isn't always precise to a particular naming or listing carrier. It can be used to get right of entry to many unique forms of systems along with record systems. The JNDI API permits packages to look up objects which includes DataSources, EJBs, MailSessions, JMS connection factories and destinations (Topics/Queues) via name.

The Objects can be loaded into the JNDI tree the usage of a J2EE software server's administration console. To load an object in a JNDI tree, select a name underneath which you want the object to appear in a JNDI tree. J2EE deployment descriptors indicate the position of J2EE components in a JNDI tree. The parameters you need to outline for JNDI service are as follows:

The call provider issuer elegance call (WsnInitialContext for WebSphere software server).

Hashtable env = new Hashtable();

env.Positioned(Context.INITIAL_CONTEXT_FACTORY,"com.Ibm.Websphere.Naming.WsnInitialContextFactory"); 

The provider URL :

The name service hostname.

The name provider port variety. 

Env.Put(Context.PROVIDER_URL, " iiop://localhost:1050");

Context ctx = new InitialContext(env); 

Q17. How Does Jndi Relate To Microsoft's Adsi?

The Java ADSI bundle lets in Java programs to get entry to Active Directory based on the COM model.

Although it can be used to get admission to different directories, it's miles a Windows-centric answer. 

JNDI offers Java applications, irrespective of whether or not they may be going for walks on Windows or accessing Active Directory, to get right of entry to directories using the Java object model. 

For instance, you can manage objects together with AWT and JavaBe components, bind them into the directory, and appearance them again up without having to do any trlation or address records representation problems.

Q18. What Is An Ldap Server ? And What Is It Used For In An Enterprise Environment ?

LDAP stands for Lightweight Directory Access Protocol. This is an extensible open community protocol fashionable that provides access to disbursed listing offerings. LDAP is an Internet fashionable for directory offerings that run on TCP/IP. Under OpenLDAP and associated servers, there are  servers slapd, the LDAP daemon in which the queries are sent to and slurpd, the replication daemon in which data from one server is driven to one or extra slave servers. By having multiple servers web hosting the equal records, you may boom reliability, scalability, and availability.

It defines the operations one may also carry out like seek, upload, delete, alter, alternate name

It defines how operations and facts are conveyed.

LDAP has the potential to consolidate all the present software specific facts like consumer, company telephone and e-mail lists. This me that the exchange made on an LDAP server will take effect on every directory provider primarily based software that uses this piece of consumer information. The type of statistics about a new person can be added via a unmarried interface with a view to be made to be had to Unix account, NT account, e mail server, Web Server, Job specific news businesses and so forth.

When the user leaves his account can be disabled to all of the offerings in a unmarried operation. So LDAP is maximum beneficial to provide "white pages" (e.G. Names, cellphone numbers, roles and so on) and "phone book (e.G. Place of printers, utility servers and many others) like services. Typically in a J2EE software surroundings it'll be used to authenticate and authorize users.

Q19. What About Security?

Different directories have one of a kind ways of dealing with protection. 

JNDI lets in for programs to work along side listing-unique protection structures. In the destiny, JNDI-based totally packages might be able to take benefit of any unmarried sign-on mechanism advanced for the Java platform.

Q20. What Is A Directory Service?

Searching for files and directories accomplished through offering Directory offerings. A directory service is a hard and fast of names. The consumer and resource data and device addresses are summarized by way of listing carrier. For example, for a given consumer name, the provider returns the attributes of the person which includes smartphone no, e-mail cope with and so forth. A listing carrier use the databases that specialized and hierarchical in design.

Q21. What Do You Know About The Directory Service Of Jndi?

Searching for files and directories done by using supplying Directory offerings. A listing service is a hard and fast of names. The consumer and useful resource records and system addresses are summarized via listing service. For example, for a given person call, the carrier returns the attributes of the user such as smartphone no, electronic mail cope with and many others. A listing provider use the databases that specialized and hierarchical in design.

Q22. What Protocols Does Jndi Provide An Interface To?

JNDI itself is unbiased of any particular directory get admission to protocol. Individual carrier vendors decide the protocols to help.

There might be provider implementations for famous protocols, together with LDAP, NDS, DNS, and NIS(YP), supplied with the aid of extraordinary providers. 

Q23. Who Should Use Jndi?

Any Java utility that wishes to get admission to statistics about users, machines, networks, and services. User information consists of security credentials, cellphone numbers, digital and postal mail addresses, and application possibilities. Machine facts consists of network addresses, system configurations, etc. In addition, any Java software that wishes to either export gadgets or get right of entry to gadgets exported by other applications and services. Examples encompass printers, calendars, and networked record systems.

Q24. Describe What Jndi Is?

JNDI is a customary listing API for Java packages. It has similarities to the java.Io.File class for gaining access to files. 

There is probably some administrative applications that need to manipulate a document on the protocol stage (along with NFS), however typically all Java packages use the File magnificence to get right of entry to to file system. 

Similarly, most Java packages ought to use JNDI to get right of entry to directories. 

Applications that want to control listing content material at the protocol level might also select to apply Netscape's API.

Q25. Why Use Ldap When You Can Do The Same With Relational Database (rdbms) ?

In popular LDAP servers and RDBMS are designed to offer exclusive types of offerings. LDAP is an open trendy access mechanism, so an RDBMS can speak LDAP. However the servers, that are constructed on LDAP, are optimized for examine access so in all likelihood to be much faster than RDBMS in providing study get admission to. So in a nutshell, LDAP is greater useful whilst the records is frequently searched but rarely changed. (Another difference is that RDBMS systems save facts in rows of tables while LDAP makes use of item oriented hierarchies of entries.) . Key LDAP Terms:

DIT: Directory Information Tree. Hierarchical shape of entries, those make up a listing.

DN: Distinguished Name. This uniquely identifies an access inside the listing. A DN is made up of relative DNs of the access and each of access's determine entries up to the basis of the tree. DN is examine from proper to left and commas separate these names. For instance 'cn=Peter Smith, o=ACME, c=AUS'.

ObjectClass: An objectClass is a formal definition of a selected form of gadgets that can be stored in the directory. An ObjectClass is a wonderful, named set of attributes that constitute something concrete such as a consumer, a laptop, or an application.

LDAP URL: This is a string that specifies the region of an LDAP useful resource. An LDAP URL includes a server host and a port, seek scope, baseDN, filter out, attributes and extensions.

LDAP schema: defines policies that specify the kinds of objects that a listing may incorporate and the specified non-compulsory attributes that entries of various kinds need to have.

Filters: In LDAP the fundamental way to retrieve information is performed with filters. There is a extensive sort of operators that may be (or), ! (no longer), ~= (approx same), >= (more than or same), <= (much less than or identical), * (any) and many others.




CFG