Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/security/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 从weblogic中的AD获取自定义用户属性_Java_Security_Ldap_Weblogic - Fatal编程技术网

Java 从weblogic中的AD获取自定义用户属性

Java 从weblogic中的AD获取自定义用户属性,java,security,ldap,weblogic,Java,Security,Ldap,Weblogic,有谁能告诉我如何使用weblogic安全性从广告中获取额外的用户属性吗? 我已配置安全提供程序并尝试在JEE应用程序中进行身份验证 HttpServletRequest request = (HttpServletRequest)((ServletRequest)ADFContext.getCurrent().getEnvironment().getRequest()); CallbackHandler handler =

有谁能告诉我如何使用weblogic安全性从广告中获取额外的用户属性吗? 我已配置安全提供程序并尝试在JEE应用程序中进行身份验证

        HttpServletRequest request =
            (HttpServletRequest)((ServletRequest)ADFContext.getCurrent().getEnvironment().getRequest());
        CallbackHandler handler =
            new SimpleCallbackHandler(username, password);               
        try {
            Subject subject = Authentication.login(handler);
            ServletAuthentication.runAs(subject, request);              
        } catch (Exception e) {
            e.printStackTrace();
            return "fail";
        }

一切都好。但从主题来看,我只能获取用户登录名和角色,但我需要用户电话和员工号码。如何操作?

主题
检索用户名后,您必须发出LDAP查询以获取额外信息。它的外观如下所示:

properties.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
properties.put(Context.PROVIDER_URL, "LDAP://yourldap:389");
properties.put(Context.SECURITY_PRINCIPAL, ldapqueryuser + "@yourldap");
properties.put(Context.SECURITY_CREDENTIALS, ldapqueryuserpassword);

// initializing active directory LDAP connection
dirContext = new InitialDirContext(properties);
dirContext.search(name, filter, cons)
这些例子非常详尽:

InitialDirContext的java文档如下: