当前位置: 首页>>代码示例>>Java>>正文


Java LdapCtx类代码示例

本文整理汇总了Java中com.sun.jndi.ldap.LdapCtx的典型用法代码示例。如果您正苦于以下问题:Java LdapCtx类的具体用法?Java LdapCtx怎么用?Java LdapCtx使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


LdapCtx类属于com.sun.jndi.ldap包,在下文中一共展示了LdapCtx类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getUsingURLIgnoreRootDN

import com.sun.jndi.ldap.LdapCtx; //导入依赖的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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:ldapURLContextFactory.java

示例2: ldapInjectionSunApi

import com.sun.jndi.ldap.LdapCtx; //导入依赖的package包/类
public void ldapInjectionSunApi(String input) throws NamingException {
    //Stub instances
    Properties props = new Properties();
    props.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    props.put(Context.PROVIDER_URL, "ldap://ldap.example.com");
    props.put(Context.REFERRAL, "ignore");

    SearchControls ctrls = new SearchControls();
    ctrls.setReturningAttributes(new String[]{"givenName", "sn"});
    ctrls.setSearchScope(SearchControls.SUBTREE_SCOPE);

    //Two context instances mostly usable with sun specific API
    LdapCtx            context5 = null;
    EventDirContext    context6 = null; //LdapCtx is the only known class to implements to this interface

    NamingEnumeration<SearchResult> answers;
    answers = context5.search(new LdapName("dc=People,dc=example,dc=com"), "(uid=" + input + ")", ctrls);
    answers = context5.search(new LdapName("dc=People,dc=example,dc=com"), "(uid=" + input + ")", new Object[0], ctrls);
    answers = context5.search("dc=People,dc=example,dc=com", "(uid=" + input + ")", ctrls);
    answers = context5.search("dc=People,dc=example,dc=com", "(uid=" + input + ")", new Object[0], ctrls);

    answers = context6.search(new LdapName("dc=People,dc=example,dc=com"), "(uid=" + input + ")", ctrls);
    answers = context6.search(new LdapName("dc=People,dc=example,dc=com"), "(uid=" + input + ")", new Object[0], ctrls);
    answers = context6.search("dc=People,dc=example,dc=com", "(uid=" + input + ")", ctrls);
    answers = context6.search("dc=People,dc=example,dc=com", "(uid=" + input + ")", new Object[0], ctrls);
}
 
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:27,代码来源:JndiLdapAdditionalSignature.java

示例3: getUsingURLIgnoreRootDN

import com.sun.jndi.ldap.LdapCtx; //导入依赖的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);
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:17,代码来源:ldapURLContextFactory.java

示例4: retrieve

import com.sun.jndi.ldap.LdapCtx; //导入依赖的package包/类
@Override
public User retrieve(String id) {
    AndFilter filter = new AndFilter();
    filter.and(new EqualsFilter("objectclass", "person"));
    filter.and(new EqualsFilter(identifierAttribute, id));

    LdapQuery ldapQuery = LdapQueryBuilder
            .query()
            .base(baseDn)
            .countLimit(1)
            .timeLimit(5000)
            .searchScope(SearchScope.SUBTREE)
            .attributes(identifierAttribute, "givenname", "sn", "mail")
            .filter(filter);

    List<User> users = ldapTemplate.search(ldapQuery, new UserAttributesMapper());
    if (users != null && ! users.isEmpty()) {
        LdapUser user = (LdapUser) users.iterator().next();
        List<String> result = ldapTemplate.search(
                baseDn, filter.encode(),
                (ContextMapper<String>) o -> ((LdapCtx) o).getNameInNamespace());
        user.setDn(result.iterator().next());

        return user;
    } else {
        return null;
    }
}
 
开发者ID:gravitee-io,项目名称:gravitee-management-rest-api,代码行数:29,代码来源:LdapIdentityLookup.java

示例5: getException

import com.sun.jndi.ldap.LdapCtx; //导入依赖的package包/类
/**
 * Retrieves the NamingException appropriate for the result code.
 *
 * @return A NamingException or null if the result code indicates
 *         success.
 */
public NamingException getException() {

    return LdapCtx.mapErrorCode(resultCode, null);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:11,代码来源:SortResponseControl.java


注:本文中的com.sun.jndi.ldap.LdapCtx类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。