dn:o=koosserydesk ObjectClass:ExtensibleObjectClass:top ObjectClass:domain dc:koosserydesk O:koosserydesk
dn:ou=Desks,o=koosserydesk ObjectClass:organizationalUnit ObjectClass:top OusseryDesk
dn:ou=Users,o=koosserydesk ObjectClass:organizationalUnit ObjectClass:top
我想让约翰米尔顿被识别为我的应用程序的认证用户时,他输入相应的UID/UserPassword。类似于:
boolean authenticate(String uid){
//我是否应该使用connection.bind(“uid=”+uid,userPassword);??
返回一些东西;}
注意,John Milton通过ApacheDS进行身份验证(用于对条目进行操作)对我来说并不是最重要的。我只想让ApacheDs为我的用户充当DB,即获取我的用户的uid,检查密码,如果它匹配返回true,或者返回false。
可能这不是我应该尝试处理这个问题的方法,但我对Ldap协议是很新的,所以不要怀疑我的问题是不是有点奇怪!
等待命题!
这可能不是重复的,但是关于以下问题的第二个答案(由Nikolay Antipov)可能会回答您的问题:如何使用给定的LDAPContext在ldap和java中检查用户密码?
这是一种解决方案,可用于通过DN以外的其他内容(例如UID
或SAMAccountName
)对用户进行身份验证。
要做的步骤是:
samAccountName
)搜索该用户代码示例:
public static boolean performAuthentication() {
// service user
String serviceUserDN = "cn=Mister Service,ou=Users,dc=example,dc=com";
String serviceUserPassword = "abc123#!$";
// user to authenticate
String identifyingAttribute = "uid";
String identifier = "maxdev";
String password = "jkl987.,-";
String base = "ou=Users,dc=example,dc=com";
// LDAP connection info
String ldap = "localhost";
int port = 10389;
String ldapUrl = "ldap://" + ldap + ":" + port;
// first create the service context
DirContext serviceCtx = null;
try {
// use the service user to authenticate
Properties serviceEnv = new Properties();
serviceEnv.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
serviceEnv.put(Context.PROVIDER_URL, ldapUrl);
serviceEnv.put(Context.SECURITY_AUTHENTICATION, "simple");
serviceEnv.put(Context.SECURITY_PRINCIPAL, serviceUserDN);
serviceEnv.put(Context.SECURITY_CREDENTIALS, serviceUserPassword);
serviceCtx = new InitialDirContext(serviceEnv);
// we don't need all attributes, just let it get the identifying one
String[] attributeFilter = { identifyingAttribute };
SearchControls sc = new SearchControls();
sc.setReturningAttributes(attributeFilter);
sc.setSearchScope(SearchControls.SUBTREE_SCOPE);
// use a search filter to find only the user we want to authenticate
String searchFilter = "(" + identifyingAttribute + "=" + identifier + ")";
NamingEnumeration<SearchResult> results = serviceCtx.search(base, searchFilter, sc);
if (results.hasMore()) {
// get the users DN (distinguishedName) from the result
SearchResult result = results.next();
String distinguishedName = result.getNameInNamespace();
// attempt another authentication, now with the user
Properties authEnv = new Properties();
authEnv.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
authEnv.put(Context.PROVIDER_URL, ldapUrl);
authEnv.put(Context.SECURITY_PRINCIPAL, distinguishedName);
authEnv.put(Context.SECURITY_CREDENTIALS, password);
new InitialDirContext(authEnv);
System.out.println("Authentication successful");
return true;
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (serviceCtx != null) {
try {
serviceCtx.close();
} catch (NamingException e) {
e.printStackTrace();
}
}
}
System.err.println("Authentication failed");
return false;
}
任务:将Kerberos active directory身份验证添加到不安全的报告和数据操作桌面应用程序。此应用程序是。。。 用Stackless Python 2.7编写 使用Twisted进行客户端-服务器交互 客户端编译为exe并在Windows上运行 服务器在Linux(红帽)上运行 目前,我们从用户帐户中提取Windows网络ID(登录名)并传递到服务器,服务器会查找用户配置为具有的权
想得到一些关于设置简单的双向ApacheSSL的建议。 我们使用openSSL创建了一个密钥文件和csr请求。然后,我们将其提交给CA,并收到一个crt文件与CA的crt文件一起返回。 我们已经配置了ApacheHTTP。conf文件,并在加载mod_ssl模块后添加了以下参数。 开启SSLEngine SSLCACertificateFile/local/fast/fcHome/deployme
我正在尝试使用ServerEvents设置servicestack。我已经为ServerEventsFeature添加了插件。我正在使用Javascript服务器事件客户端,我尝试了一个简单的示例,在用户经过身份验证后在客户端上执行此操作。 在apphost文件上: 要向我正在呼叫的客户端发送事件,请执行以下操作: 我成功地在客户端上的show通知功能上接收到它。 然而,订阅服务仍然存在。disp
如何使用spring oauth2和DB实现资源服务器和身份验证服务器,以及如何使用以下模式:https://github.com/spring-projects/spring-security-oauth/blob/master/spring-security-oauth2/src/test/resources/schema.sql 测试数据会很棒!!!
我正在为我们的应用程序使用Spring boot Microservices体系结构。在我们的项目中,我们使用的是OAuth2、Jwt、Zuul和Eureka服务,我的疑问是,我是否需要将这些服务作为一个独立的服务来实现,或者我是否可以将所有服务开发成一个单一的应用程序。 如果我必须作为单个应用程序实现,那么更好的方法是什么。请澄清
我试图扩展用户身份验证示例,这里也给出了这个示例,以便多个用户可以登录到服务器。我还想为每个用户分配一个不同的主目录。到目前为止,我还没有找到Apache SSHD API提供的任何此类实用程序,因此我尝试了以下解决方案,使用Apache FTPServer提供的实用程序。 我试图做的是: