How to log in to apacheds with non-admin user

I am trying to log in with a user to ApacheDS through Java. This are my user's details as exported in an ldif: dn: uid=carlspring,ou=users,ou=system objectClass: top objectClass: inetOrgPerson objectClass: person objectClass: organizationalPerson cn: Martin Todorov sn: Todorov uid: carlspring userPassword:: e1NTSEF9bC9LRk45RllHdW5aVGdLcUtScmNTYk80RXRLMmJvbTEvM2NOYnc9PQ== This is the code I have: // Set up environment for creating initial context Hashtable env = new Hashtable(11); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, "ldap://localhost:10389/ou=users,ou=system"); env.put(Context.SECURITY_AUTHENTICATION, "simple"); env.put(Context.SECURITY_PRINCIPAL, "uid=carlspring,ou=users,ou=system"); env.put(Context.SECURITY_CREDENTIALS, "password"); try { // Create initial context DirContext ctx = new InitialDirContext(env); System.out.println(ctx.lookup("ou=users")); System.out.println("Logged in."); // do something useful with ctx // Close the context when we're done ctx.close(); } catch (NamingException e) { e.printStackTrace(); } I am getting the following exception: javax.naming.NameNotFoundException: [LDAP: error code 32 - NO_SUCH_OBJECT: failed for MessageType : SEARCH_REQUEST Message ID : 2 SearchRequest baseDn : 'ou=users,ou=users,ou=system' filter : '(objectClass=*)' scope : base object typesOnly : false Size Limit : no limit Time Limit : no limit Deref Aliases : deref Always attributes : org.apache.directory.api.ldap.model.message.SearchRequestImpl@c7594470 ManageDsaITImpl Control Type OID : '2.16.840.1.113730.3.4.2' Criticality : 'false' ' : ERR_648 Invalid search base ou=users,ou=users,ou=system]; remaining name 'ou=users' From what I understand, it doesn't seem to be connecting properly. I've tried logging in through Apache Directory Studio (with `uid=carlspring,ou=users,ou=system`) and that works fine. I can also log in with the admin user like this: env.put(Context.PROVIDER_URL, "ldap://localhost:10389/ou=system"); env.put(Context.SECURITY_PRINCIPAL, "uid=admin,ou=system"); env.put(Context.SECURITY_CREDENTIALS, "secret"); Could somebody please tell me what I'm doing wrong and why it's not logging in? I can't seem to be able to figure it out. Many thanks in advance!

以上就是How to log in to apacheds with non-admin user的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏