Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/378.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.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 OpenLDAP-DirContextOperations.search((字符串名称、字符串筛选器、SearchControls))_Java_Spring Boot_Spring Security_Openldap - Fatal编程技术网

Java OpenLDAP-DirContextOperations.search((字符串名称、字符串筛选器、SearchControls))

Java OpenLDAP-DirContextOperations.search((字符串名称、字符串筛选器、SearchControls)),java,spring-boot,spring-security,openldap,Java,Spring Boot,Spring Security,Openldap,需要使用搜索方法检索“memberOf”属性,但出现以下错误。请告诉我如何检索代码 java.lang.UnsupportedOperationException: Not implemented. at org.springframework.ldap.core.DirContextAdapter.search(DirContextAdapter.java:1055) ~[spring-ldap-core-2.3.3.RELEASE.jar:2.3.3.RELEASE] at com.exam

需要使用搜索方法检索“memberOf”属性,但出现以下错误。请告诉我如何检索代码

java.lang.UnsupportedOperationException: Not implemented.
at org.springframework.ldap.core.DirContextAdapter.search(DirContextAdapter.java:1055) ~[spring-ldap-core-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at com.example.authenticatingldap.WebSecurityConfig$1.mapUserFromContext(WebSecurityConfig.java:85) ~[classes/:na]
at org.springframework.security.ldap.authentication.AbstractLdapAuthenticationProvider.authenticate(AbstractLdapAuthenticationProvider.java:82) ~[spring-security-ldap-5.4.5.jar:5.4.5]
这是我编写的代码,这里我需要获取详细信息的成员并为用户设置权限/角色。非常感谢您的帮助 //代码

@配置
@启用Web安全性
公共类SecurityConfiguration 2扩展了WebSecurity配置适配器{``
@自动连线
服务器详细信息存储服务器详细信息存储;
@自动连线
角色还原性角色还原性;
@值(${login\u admin\u role\u api\u list}”)
私有字符串LoginAdminRoleAlist``
@值(${login\u all\u role\u api\u list}”)
私有字符串loginalleresapillist;
@值(${login\u admin\u readwrite\u role\u api\u list}”)``
私有字符串loginAdminReadWriterLeapIList;
/*
*@Override protected void configure(HttpSecurity http)引发异常{
*System.out.println(“内部HttpSecurity方法”);http.authorizeRequests()
*.anyRequest().fullyAuthenticated()和().formLogin();}
*/
@自动连线
public void configureGlobal(AuthenticationManagerBuilder authBuilder)引发异常{
authBuilder.ldaAuthentication()。
userSearchBase(“ou=people,dc=sdnlab,dc=com”)。
userSearchFilter(“(uid={0})”)
.userDnPatterns(“uid={0},ou=people”).userDetailsContextMapper(userDetailsContextMapper())
.contextSource().root(“dc=sdnlab,dc=com”)
.url(“ldap://10.168.160.104:389/dc=sdnlab,dc=com”);
}
@豆子
公共UserDetailsContextMapper UserDetailsContextMapper(){`
返回新的LdapUserDetailsMapper(){
@抑制警告(“未使用”)
@凌驾
公共用户详细信息mapUserFromContext(DirContextOperations ctx,字符串用户名,

集合您可以如下所示为的成员设置搜索筛选器

StringBuilder searchFilter = new StringBuilder(
                "(&(objectCategory=Person)(objectclass=user)(sAMAccountName={0})(memberOf=CN=");
        searchFilter.append(ldapGroup).append(",OU=Groups,OU=Accounts,DC=nos,DC=abc,DC=com))"); // nos.abc.com
        
        BindAuthenticator authenticator = new BindAuthenticator(ctxSrc);
        authenticator.setUserSearch(new FilterBasedLdapUserSearch("", searchFilter.toString(), ctxSrc));
        authenticator.afterPropertiesSet();

        Authentication authenticationObj = new UsernamePasswordAuthenticationToken(username, password);

        DirContextOperations user = authenticator.authenticate(authenticationObj);
然后您可以获得用户属性

 LOG.debug("UID string: " + user.getAttributes());

已尝试字符串[]memberOfs=ctx.getStringAttributes(“memberOf”);但没有帮助在LDAP:ldapsearch-x-LLL-H LDAP://-b“uid=praveen,ou=people,dc=sdnlab,dc=com”中搜索查询dn memberof output:dn:uid=praveen,ou=people,dc=sdnlab,dc=com memberof:cn=tafadmin,ou=groups,dc=sdnlab,dc=com*/建议我哪里出错了?为什么我不能?你确定有
memberof
attattributes吗?
memberof
是一个可操作的属性。除非你明确要求,否则你得不到它具有
“+”
.NB
对象[]组的操作属性2=新对象[100];
:在下一行分配变量时,您不需要初始化变量。我已经编辑了查询并粘贴了正在使用的代码,您能告诉我为什么这个searh方法不起作用吗?它不会检索
的memberOf
或任何其他操作属性。您还没有尝试过这个方法。
 LOG.debug("UID string: " + user.getAttributes());