Search in sources :

Example 1 with LdapURL

use of com.sun.jndi.ldap.LdapURL in project jdk8u_jdk by JetBrains.

the class ldapURLContextFactory method getUsingURLIgnoreRootDN.

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);
}
Also used : LdapURL(com.sun.jndi.ldap.LdapURL) LdapCtx(com.sun.jndi.ldap.LdapCtx) DirContext(javax.naming.directory.DirContext)

Example 2 with LdapURL

use of com.sun.jndi.ldap.LdapURL in project jdk8u_jdk by JetBrains.

the class ldapURLContext method getURLSuffix.

/**
     * 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;
}
Also used : LdapURL(com.sun.jndi.ldap.LdapURL)

Example 3 with LdapURL

use of com.sun.jndi.ldap.LdapURL in project jdk8u_jdk by JetBrains.

the class ldapURLContext method searchUsingURL.

// Search using the LDAP URL in name.
// LDAP URL query components override the search argments.
private NamingEnumeration<SearchResult> searchUsingURL(String name) throws NamingException {
    LdapURL url = new LdapURL(name);
    ResolveResult res = getRootURLContext(name, myEnv);
    DirContext ctx = (DirContext) res.getResolvedObj();
    try {
        return ctx.search(res.getRemainingName(), setFilterUsingURL(url), setSearchControlsUsingURL(url));
    } finally {
        ctx.close();
    }
}
Also used : LdapURL(com.sun.jndi.ldap.LdapURL) ResolveResult(javax.naming.spi.ResolveResult)

Example 4 with LdapURL

use of com.sun.jndi.ldap.LdapURL in project jdk8u_jdk by JetBrains.

the class LdapUnicodeURL method main.

public static void main(String[] args) throws Exception {
    // First 3 characters of the CJK Unified Ideographs
    String uid = "uid=一丁丂";
    LdapURL ldURL = new LdapURL("ldap://www.example.com/" + uid);
    if (!ldURL.getDN().equals(uid)) {
        throw new Exception("uid changed to " + ldURL.getDN());
    }
}
Also used : LdapURL(com.sun.jndi.ldap.LdapURL)

Aggregations

LdapURL (com.sun.jndi.ldap.LdapURL)4 LdapCtx (com.sun.jndi.ldap.LdapCtx)1 DirContext (javax.naming.directory.DirContext)1 ResolveResult (javax.naming.spi.ResolveResult)1