本文整理汇总了Java中com.sun.jndi.ldap.LdapURL.getDN方法的典型用法代码示例。如果您正苦于以下问题:Java LdapURL.getDN方法的具体用法?Java LdapURL.getDN怎么用?Java LdapURL.getDN使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.jndi.ldap.LdapURL
的用法示例。
在下文中一共展示了LdapURL.getDN方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getUsingURLIgnoreRootDN
import com.sun.jndi.ldap.LdapURL; //导入方法依赖的package包/类
static ResolveResult getUsingURLIgnoreRootDN(String url, Hashtable<?,?> env)
throws NamingException {
LdapURL ldapUrl = new LdapURL(url);
DirContext ctx = new LdapCtx("", ldapUrl.getHost(), ldapUrl.getPort(),
env, ldapUrl.useSsl());
String dn = (ldapUrl.getDN() != null ? ldapUrl.getDN() : "");
// Represent DN as empty or single-component composite name.
CompositeName remaining = new CompositeName();
if (!"".equals(dn)) {
// if nonempty, add component
remaining.add(dn);
}
return new ResolveResult(ctx, remaining);
}
示例2: getURLSuffix
import com.sun.jndi.ldap.LdapURL; //导入方法依赖的package包/类
/**
* Return the suffix of an ldap url.
* prefix parameter is ignored.
*/
protected Name getURLSuffix(String prefix, String url)
throws NamingException {
LdapURL ldapUrl = new LdapURL(url);
String dn = (ldapUrl.getDN() != null? ldapUrl.getDN() : "");
// Represent DN as empty or single-component composite name.
CompositeName remaining = new CompositeName();
if (!"".equals(dn)) {
// if nonempty, add component
remaining.add(dn);
}
return remaining;
}
示例3: main
import com.sun.jndi.ldap.LdapURL; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
// First 3 characters of the CJK Unified Ideographs
String uid = "uid=\u4e00\u4e01\u4e02";
LdapURL ldURL = new LdapURL("ldap://www.example.com/" + uid);
if (!ldURL.getDN().equals(uid)) {
throw new Exception("uid changed to " + ldURL.getDN());
}
}