⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readme

📁 在JAVA编程中对JNDI的支持.是一个开放的源码.
💻
字号:
This directory contains example programs showing how to use the JNDIAPI. They can be used to access any JNDI service provider you haveconfigured for your environment.For expediency, these examples use the Java system properties for JNDIenvironment properties.  This usage is not meant to be prescriptiveand is but one of the many ways to set up environment properties.First, use JDK1.1.2 to compile all four .java files to generatecorresponding .class files.To run these examples, make sure that your class path includes theJNDI classes, the classes for your service providers, and the classesof these examples.When running the programs, you need to specify as system propertiesjava.naming.factory.initial and any environment properties expected byyour service provider. (See examples below).You can then run these examples as follows (substitute the names ofthe maps and entries appropriate for your environment).  $P denotesthe system property settings.# java $P Attrs <name># java $P List [<name>]# java $P List -b [<name>]# java $P Search <name> [<attrid> <attrval>]*# java $P Lookup <name>--------------------------------------------------------Examples accessing LDAP using the JNDI/LDAP provider:LP="-Djava.naming.factory.initial=com.sun.jndi.ldap.LdapCtxFactory \	-Djava.naming.provider.url=ldap://servername/o=widget,c=us"Here are some examples of accessing LDAP using these examples:To see a list of the top level LDAP namespace:# java $LP List----To browse one of the lower levels:# java $LP List ou=people----To get an object's attributes:# java $LP Attrs "cn=John Smith,ou=people"----To search for an object with uid=jsmith:# java $LP Search ou=people uid jsmith---------------------------------------------------------Examples access NIS using the JNDI/NIS provider:NP="-Djava.naming.factory.initial=com.sun.jndi.nis.NISCtxFactory \	-Djava.naming.provider.url=nis://servername/eng.widget.com"To see a list of the initial context:# java $NP List ----To see a list of the NIS maps:# java $NP List system----You can use to Attrs program to discover the various attributeidentifiers assigned to the data in various maps. For example,# java $NP Attrs system/passwd/jsmithshows all the attributes associated with the entry jsmith in thepasswd map.----To search for an object with uid=jsmith:# java $NP Search system/passwd uid jsmith----To provide consistency between information stored in NIS and informationstored in LDAP, the identifiers of the attributes used to represent NISmaps are taken from internet draft "draft-ietf-asid-nis-schema-02".-----------------------------------------------------------Examples using the JNDI URL:JNDI URLs may used for naming objects in a federated namespace rootedat DNS.JNDI URLs have the following syntax:	jndi://dnsname/composite_nameThis means that composite_name is to be resolved in the context namedby DNS record(s) associated with "dnsname".If "dnsname" is omitted, as in this example:	jndi:///composite_namethen composite_name is resolved in the initial context.  In this case thethree slashes may optionally be omitted, and the URL written as:	jndi:composite_nameFor an application to use the DNS federation aspect of JNDI URLs, itmust identify its DNS server by setting the java.naming.dns.url property:JP="-Djava.naming.dns.url=dns://dnsserver/dnsdomain"Assume that the records associated with "dns1" in the local DNSdomain indicate an LDAP server with root distinguished name"o=widget,c=us".  Then:# java $JP Attrs "jndi://dns1/cn=John Smith,ou=people"retrieves the attributes associated with the namecn=John Smith,ou=people,o=widget,c=us----The format currently being used for storing location information in DNSis based upon the internet draft "draft-ietf-svrloc-advertising-02".Following this model, the above example relies on a TXT recordbeing stored in the DNS node "dns1":dns1 IN TXT service:j-ldap://servername/o=widget,c=us----Assume that the DNS node associated with "dns2" in your domain indicatesan NIS server for the domain widget.com.  Then:# java $JP List jndi://dns2/system/passwdwill list the password entries in the widget.com NIS domain.The TXT record stored in DNS at "dns2" for this example is:dns2 IN TXT service:j-nis://servername/widget.com-------------------------------------------------------------Using policies to hide naming service dependencies:With DNS configured as described above, the following searches willfind the attributes associated with user "jsmith" in a NIS domain andin an LDAP directory, respectively:# java $JP Search jndi://dns2/system/passwd uid jsmith# java $JP Search jndi://dns1/ou=people uid jsmithAlthough the use of federation through DNS hides some of the detailsof which underlying service is being accessed, the different styles ofsyntax used by the services gives some of it away.To allow applications to be written in a more service-neutral style,a context implementation may support the notion of a policy mapping.Policies are used to translate a few service-neutral names intonames that may be used directly by the underlying services.For example, the NIS provider hardwires the name "user" as an aliasfor "system/passwd", so the following two searches are equivalent:# java $JP Search jndi://dns2/system/passwd uid jsmith# java $JP Search jndi://dns2/user uid jsmithRather than hardwiring policies, the LDAP provider accepts policies inthe form of an environment property "java.naming.ldap.policies".  Its valueis a string containing each policy component and its mapping onto LDAP.The first character of the string is the delimiter used throughout the string.For example, the name "user" may be mapped onto the LDAP name "ou=people":POL=-Djava.naming.ldap.policies=:user:ou=people:Then the following two searches are equivalent:# java $JP $POL Search jndi://dns1/ou=people uid jsmith# java $JP $POL Search jndi://dns1/user uid jsmithNow, a user or application can search for user "jsmith" first in a NISdomain, and then in an LDAP directory, in a generic manner:# java $JP $POL Search jndi://dns2/user uid jsmith# java $JP $POL Search jndi://dns1/user uid jsmith-------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -