创建可以验证登录的内存 LDAP 服务器,如域\用户名。 unboundid 不起作用

时间:2021-07-15 06:54:02

标签: ldap unboundid-ldap-sdk unboundid

这是一个旧代码,我正在为其编写端点测试,我需要一个内存中的 LDAP SERVER 来模拟实际的 ldap。因此无法更改 ....... FROM MyTable AS tbl_a OUTER APPLY (SELECT CAST(tbl_a.VarcharMaxColumn AS xml) AS ConvertedXml) AS cast_xml CROSS APPLY cast_xml.ConvertedXml.nodes('/MyProperties/*') AS my_properties_nodes(xml_frag) ....... 中的任何内容。

服务器代码。

test code

测试代码

InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig("dc=sciencelogic");
            //config.addAdditionalBindCredentials("cn=Directory Manager", "password");
            config.setListenerConfigs(InMemoryListenerConfig.createLDAPConfig("default", 1389));
            config.setSchema(null);
            InMemoryDirectoryServer ds = new InMemoryDirectoryServer(config);
            ds.startListening();
            ds.importFromLDIF(true, new LDIFReader(getClass().getResourceAsStream("realm.ldif")));

LDIF 文件。

authDomainServerIP = "localhost:1389";//oCache.getItemKeyValue("authenticationDomainServerIP");
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.SECURITY_AUTHENTICATION, "simple");
    env.put(Context.PROVIDER_URL, "ldap://"+authDomainServerIP);

    // The value of Context.SECURITY_PRINCIPAL must be the logon username with the domain name
    env.put(Context.SECURITY_PRINCIPAL, "sciencelogic\\tkrilly");

    // The value of the Context.SECURITY_CREDENTIALS should be the user's password
    env.put(Context.SECURITY_CREDENTIALS, "password");

异常信息。

dn: dc=sciencelogic
objectClass: top
objectClass: domain
dc: server


dn: uid=tkrilly,dc=sciencelogic
uid: tkrilly
sAMAccountName: tkrilly
userPrincipalName: tkrilly
cn: Ted Krilly
objectClass: top
objectClass: person
objectClass: inetOrgPerson
userPassword: password
street: 100 Commonwealth Avenue
l: Boston
st: MA
postalCode: 02134
mail: tkrilly@company.com
telephoneNumber: 617-776-2661
mobile: 617-776-3000
givenName: Ted
sn: Krilly

0 个答案:

没有答案
相关问题