简体   繁体   English

LDAP的JBoss连接配置

[英]JBoss connection configuration for LDAP

I want to use JBoss AS 7.1 server's connection pooling to configure the LDAP server. 我想使用JBoss AS 7.1服务器的连接池来配置LDAP服务器。 I will be writing a java program to connect to LDAP server configured in the above step and retrieve the user information. 我将编写一个Java程序以连接到上述步骤中配置的LDAP服务器并检索用户信息。 The java class will be a part of war file I will be deploying to the same JBoss server later on. java类将成为war文件的一部分,稍后我将将其部署到同一JBoss服务器。 Can somebody help with what xml file in which location needs to be modified to have the LDAP information and also a small code snippet in java class that reads the configurations and connects to the LDAP server. 有人可以帮忙修改需要修改位置的xml文件以获取LDAP信息,以及java类中的一小段代码片段,以读取配置并连接到LDAP服务器。 I ahve something very simple in a java file which connects to the LDAP server and gets the info. 我在连接到LDAP服务器并获取信息的java文件中有一个非常简单的东西。 as shown below: 如下所示:

        Hashtable env = new Hashtable();  
        env.put(Context.INITIAL_CONTEXT_FACTORY,  
                "com.sun.jndi.ldap.LdapCtxFactory");  
        env.put(Context.SECURITY_AUTHENTICATION, "Simple");  
        env.put(Context.SECURITY_PRINCIPAL, "cn=Manager, dc=maxcrc,dc=com");  
        env.put(Context.SECURITY_CREDENTIALS, "secret");  
        env.put(Context.PROVIDER_URL, "ldap://localhost:389");

Also if I have the password encrypted in the config file is there a utility provided by JBoss framework to decrypt the password while connecting to the server or should I write the method in my java class to decrypt and send it across. 另外,如果我在配置文件中加密了密码,那么JBoss框架提供了一个实用程序,可以在连接服务器时对密码进行解密,或者我应该在Java类中编写该方法进行解密并将其发送出去。 I won't be using JBoss LDAP authentication. 我不会使用JBoss LDAP认证。 I saw some posts with login-config files which won't help my situation. 我看到了一些带有login-config文件的帖子,这些帖子对我的情况没有帮助。 Thanks. 谢谢。

I'm out of time to test now but I believe you need to use an ExternalContext to achieve your goal. 我没有时间进行测试,但是我相信您需要使用ExternalContext来实现您的目标。

See this link: https://access.redhat.com/site/documentation/en-US/JBoss_Enterprise_Web_Platform/5/html/Administration_And_Configuration_Guide/Additional_Naming_MBeans-org.jboss.naming.ExternalContext_MBean.html 请参阅以下链接: https : //access.redhat.com/site/documentation/zh-CN/JBoss_Enterprise_Web_Platform/5/html/Administration_And_Configuration_Guide/Additional_Naming_MBeans-org.jboss.naming.ExternalContext_MBean.html

Then see this: https://community.jboss.org/thread/175856 然后看这个: https : //community.jboss.org/thread/175856

I really believe this is the way :) 我真的相信这是方法:)

Best, -- Mauricio 最好-毛里西奥

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM