NIS+ Service Provider for the
Java (TM)Naming Directory InterfaceTM (JNDI)


Please send feedback to [email protected]

Table of Contents


Introduction

NIS is Network Information Service. It is the network-wide system database used by Solaris and other Unix(TM)-based operating system for storing information related to users, machines and network services.

The NIS service provider implements the DirContext interface. You can use this provider with JNDI in order to access NIS service. The provider presents the data in NIS maps as JNDI DirContext and Attribute objects using the IETF RFC 2307.

This document describes the features of the NIS service provider and contains details of how JNDI is mapped to the NIS operations.


Conformance

The NIS service provider supports Version 2 of the NIS protocol. It does not support any of the ancillary protocols (such as those for updating password or public keys).

RFC 2307 describes the mapping of NIS map entries to X.500/LDAP-style entries. The NIS service provider uses this mapping to present the data it obtains from the NIS service.

The NIS provider supports the standard NIS maps using the mapping described in the RFC. Nonstandard maps can be accessed as well, but their entries are not parsed into separate attributes.


Environment Properties

The following JNDI environment properties are relevant for the NIS service provider. See the JNDI documentation for a description of how properties are initialized using the environment properties, system properties, applet parameters, and resource files.

java.naming.factory.initial
This environment property is used to select the NIS provider; it's not actually used by the provider itself. It specifies the class name of the initial context factory for the provider.

For example:

env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.nis.NISCtxFactory");

This environment property must be set if you are using the NIS provider for the initial context. The only exception is if you supply only URLs to the initial context, in which case, you don't need to specify this property. See the Types of Contexts and how Objects are Named section for details.

java.naming.provider.url
Specifies NIS server information. The valid formats of the URL expected by the NIS service provider are:

nis:///
nis:///
nis:/
nis:
where specifies a host name or IP address of the server offering NIS service for the NIS domain . If is not specified, the NIS provider broadcasts on the local subnet for a server. If none is found, JNDI methods that use the provider will fail.

For example, this setting:

env.put(Context.PROVIDER_URL, "nis://megasvr/eng.widget.com");
will cause the provider to contact the server megasrv to access the NIS service for the NIS domain eng.widget.com.

If this property is not set, or if is not found or does not serve the NIS domain , JNDI calls that use the provider will fail.

java.naming.factory.object
A colon-separated list of the fully qualified class names of object factory classes for transforming objects read from the NIS server. You can use this mechanism to transform an object into forms expected by the application. See javax.naming.spi.DirectoryManager.getObjectInstance() for details.
com.sun.jndi.nis.mailaliases
If the value is the string "nonull", the NIS mailaliases map assumes that keys are terminated by whitespace instead of null. The NIS server that ships with Solaris uses null terminated strings for keys. If you are using an NIS server that does not do this, you need to set this property. By default, mail.aliases and mail.byaddr maps are assumed to have null-terminated keys and values.

Types of Contexts and how Objects are Named

There are three types of contexts in the NIS provider:

In the initial context, there are three names: system, user, host. "system" is bound to the map-list context, which contains a list of the maps found in the NIS service. You can name a map using its full map name (e.g. "passwd.byname") or using its alias (e.g. "passwd"). Standard maps that contain the same information but using different keys are from the JNDI perspective the same context. For example, both "passwd.byname" and "passby.byuid" point to the same context.

Only standard NIS maps have aliases. Nonstandard maps must be named using their full map name as they appear on the server.

"user" is a shortcut for "system/passwd.byname".

"host" is a shortcut for "system/hosts.byname".

Each map context presents the contents of a single NIS map. To name an entry within a map, use the primary key for the primary map. For example, "system/passwd/jsmith" names the entry with user name jsmith in the passwd map.

The attributes of entries in a map have String values as specified in RFC 2307. The entries of each map (including those not described in RFC 2307) have the attributes "cn", "nisMapName", and "nisMapEntry", the definitions of which are in RFC 2307. The only exception is the optional "userPassword" attribute that is found in the paswd.byname and group.byname maps. The value of this attribute is of type byte[] instead of String (because according to RFC2307, its value is an octet string, not character string).

You can also supply NIS URLs to the initial context. For example,

	
ictx.list("nis://ypserver/eng.widget.com/user");

will list all the NIS entries in the passwd.byname map.


API Mapping

The NIS protocol does not support updates and hence all the JNDI update-related methods are not supported. DirContext methods are mapped onto NIS operations as follows.

addToEnvironment()
Environment properties can be added or changed via this method, but such changes do not affect the current context.
bind()
This method is not supported because the NIS protocol does not support updates.
close()
Releases any internal data structures used.
composeName()
Concatenates two names.
createSubcontext()
This method is not supported because the NIS protocol does not support updates.
destroySubcontext()
This method is not supported because the NIS protocol does not support updates.
getAttributes()
Maps and entries in maps have attributes. The contents of an NIS entry is mapped to attributes according to RFC 2307. An entry always contains the following three attributes: "cn", "nisMapName", "nisMapEntry". Therefore, the contents of an entry from a nonstandard map or one that does not have a schema defined in RFC 2307 can be accessed using these attributes. A map has the attributes "objectclass" and "nisMapName" (see nisMap in RFC 2307).
getEnvironment()
Returns the environment properties associated with this context.
getNameInNamespace()
Returns the name of this map or entry. For a map, this is the map's name (e.g., "passwd.byname"), and for an entry, this is the entry's primary key.
getNameParser()
Returns a name parser for flat names.
getSchema()
NOTE: This method is currently not supported. In the future, it will return schema information as described by RFC 2307.
getSchemaClassDefinition()
NOTE: This method is currently not supported. In the future, it will return schema information as described by RFC 2307.
lookup()
lookupLink()
lookup() on a map returns a context that can be used to list it. lookup() on a map entry returns a DirContext. DirectoryManager.getObjectInstance() is invoked on the object before it is returned in case the application or user has supplied object factories.
list()
listBindings()
A list on the "system" context returns a list of the maps served by the NIS server. A list on an NIS map returns a list of entries in that map. DirectoryManager.getObjectInstance() is called when getObject() is invoked on the resulting enumeration in case the application or user has supplied object factories.
modifyAttributes()
This method is not supported because the NIS protocol does not support updates.
removeFromEnvironment()
Environment properties can be removed via this method but such action does not affect the current context.
rebind()
This method is not supported because the NIS protocol does not support updates.
rename()
This method is not supported because the NIS protocol does not support updates.
search()
search() works for all contexts, except when the search scope is specified as SUBTREE_SCOPE (in which case you get an OperationNotSupportedException). Some forms of string filters can make use of a map's index(es). Although more complex filters are also supported (such as wildcards and logical expressions), the performance of the search operation when such filters are used are dependent upon the size of the map because it cannot use any of the indexes associated with the map. This means it can be very slow when the map is very large. DirectoryManager.getObjectInstance() is called when getObject() is invoked on the resulting enumeration in case the application or user has supplied object factories.
unbind()
This method is not supported because the NIS protocol does not support updates.

Federation

The NIS service provider supports federation using weak separation and implicit next naming system pointer. Specifically, the context named by an entry in a map supports federation in this way. For example, you can name an object such as "system/passwd/jsmith/xyz" where xyz names an object in a namespace federated beyond the NIS namespace, at the entry jsmith in the passwd.byname map.



Copyright � 1999 Sun Microsystems, Inc., All Rights Reserved.