亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

spring LDAP模板認證

spring LDAP模板認證

大話西游666 2021-09-03 15:41:23
我正在嘗試通過 spring ldap 對用戶進行身份驗證。以下是初始化 ldap 模板的代碼。contextSource = new LdapContextSource();contextSource.setUrl("ldaps://ldap.example.com");contextSource.setBase("DC=example,DC=com");contextSource.setUserDn("backend-app");contextSource.setPassword("password");contextSource.afterPropertiesSet();PoolingContextSource pooledContextSource = new PoolingContextSource(); pooledContextSource.setDirContextValidator(new DefaultDirContextValidator());pooledContextSource.setContextSource(contextSource);ldapTemplate =  new LdapTemplate(pooledContextSource); ldapTemplate.afterPropertiesSet();當我嘗試使用 ldapTemplate 身份驗證方法時,它返回 false。// below line failsldapTemplate.authenticate("OU=Service Accounts,OU=Pseudo-Users", "frontend-web", "password");但是當我使用目錄上下文時它可以工作DirContext ctx = null;try {  ctx = contextSource.getContext("frontend-web", "password");  return true;} catch (Exception e) {  logger.error("Login failed", e);  return false;} finally {  LdapUtils.closeContext(ctx);  }問題 1:無論如何要使 ldaptemplate 身份驗證方法起作用嗎?問題二:直接使用DirectoryContext時為什么不用提供baseDn。ldap 如何知道在哪里可以找到用戶“frontend-web”。它是否在整個目錄中搜索用戶“frontend-web”任何人都可以幫忙。
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 578 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號