2019年5月28日更新
我使用的是来自org.springframework.security.ldap.authentication.ad的ActiveDirectoryLdapAuthenticationProvider,searchForUser方法能够通过电子邮件找到用户。
我使用默认的searchFilter:(&(objectClass=user)(userPrincipalName={0}))。
但如果将networkID作为用户名提供,则不起作用。所以:
employee@PublicCompanyEmail.com工作正常
employee_AD_username@internaldomain.com不工作
感谢任何关于它的想法!
发布于 2019-05-29 04:44:35
先介绍一些术语
安全帐户管理器(SAM)名称
The networkID you use to login to the network.用户主体名称(UPN)
It may be Implicit UPN (iUPN) or Explicit UPN (eUPN).
An example for iUPN would be: networkID@internalDomain.com
An example for eUPN would be: employee_name@companyName.com
eUPN may be defined by network administrator.
In my case, the UPN we're using in our AD is actually an eUPN.搜索筛选器语法
This is query language for AD.
We used it to define the filter while searching for objects in AD.
{0}-occurrence means full username with domain in it. If the domain is defined in LDAP configuration then Spring Security checks if it's present in the entered username to login. If not, then it'll be added.
{1}-occurrence means whatever entered as username. So, Spring won't do any modification on the provided username.如果您想在不提供域名的情况下登录,则需要在LDAP配置中定义域
ActiveDirectoryLdapAuthenticationProvider provider = new ActiveDirectoryLdapAuthenticationProvider(
"domain",...);然后,如果它是电子邮件地址中使用的域,则此过滤器:
(&(objectClass=user)(userPrincipalName={0}))将找到包含和不包含域名的用户。
如果配置的域是内部域,则此筛选器:
(&(objectClass=user)(sAMAccountName={1}))如果提供的用户名是不带doamin的networkID,则会找到用户。
如果您没有为LDAP配置定义域,并且在实例化对象时将其保留为空,那么您应该能够搜索出现{1}次的UPN和sam用户名,但是您必须在登录时提供networkID和电子邮件用户名的域。
发布于 2019-05-23 05:42:43
哈哈,你陷入了eUPN和iUPN的问题。您的公司使用UPN后缀为每个用户创建一个虚拟域,并将其虚拟企业UPN存储在userPrincipalName字段中。一旦隐式UPN (Kerberos主体)被企业UPN覆盖,您就不走运了。
你可能想要考虑一些更好的东西,而不是一遍又一遍地用用户名和密码纠缠你的用户,至少在again...at上你可以使用this,如果你可以在Spring Security中使用<security:jee>的话。
https://stackoverflow.com/questions/56264910
复制相似问题