Tag: ldapconnection

在LDAP中实现超时

我一直在处理我们使用LDAP获取用户详细信息的应用程序。 有时需要更多时间来获取用户详细信息。 我想在获取详细信息的方法上实现超时 ,以便在最坏的情况下我们可以避免在服务器中挂起事务。 这里我们使用LdapUtil类,我们在其中配置了LdapTemplate类来获取所需的详细信息。 我们如何在LDAP方法上实现超时? (在本例中为ldapTemplate.search(…)方法) public class LdapUtil { @Autowired(required = true) @Qualifier(value = “ldapTemplateApp”) LdapTemplate ldapTemplate; public Set findProducts(String UserId) { final Set products = newHashSet(); // Lookup the user String usrFilter = String.format(USERID_FILTER, globalUserId); ldapTemplate.search(“ou=Members”, usrFilter, // note this line new NameClassPairCallbackHandler() { public void handleNameClassPair(NameClassPair nameClassPair) { SearchResult result = […]

使用Java从LDAP检索所有用户及其角色

我有一个Web应用程序。 对于LDAP,我使用的是Apache Directive Studio。 我想在我的应用程序中获取所有用户及其角色。 我可以使用以下代码获取特定信息。 import java.util.Properties; import javax.naming.Context; import javax.naming.NamingException; import javax.naming.directory.Attributes; import javax.naming.directory.DirContext; import javax.naming.directory.InitialDirContext; public class DirectorySample { public DirectorySample() { } public void doLookup() { Properties properties = new Properties(); properties.put(Context.INITIAL_CONTEXT_FACTORY, “com.sun.jndi.ldap.LdapCtxFactory”); properties.put(Context.PROVIDER_URL, “ldap://localhost:10389”); try { DirContext context = new InitialDirContext(properties); Attributes attrs = context.getAttributes(“dc=example,dc=com”); System.out.println(“ALL Data: ” + attrs.toString()); […]

LDAP:如何使用连接详细信息validation用户身份

我无法使用LDAP对用户进行身份validation。 我有以下细节: URL=ldap://10.10.10.10:389 LDAP BASE:DC=lab2,DC=ins LDAP Bind Account: CN=Ldap Bind,OU=Service Accounts,OU=TECH,DC=lab2,DC=ins LDAP Bind Account Pw: secret 我可以使用上面的详细信息搜索sAMAccountName值,但是如何使用用户名和密码validation用户? 如果您按照我之前的问题进行操作,那么您将了解到,我已成功连接到LDAP服务器但无法对其进行身份validation。 用户进行身份validation: user: someusername password: somepwd 我无法使用’somepwd’连接到LDAP服务器,我应该如何使用someusername 。 我能够将给定用户搜索为sAMAccountName 。