LDAP搜索与UPN Active Directory中的用户 [英] LDAP Searching a user in Active directory with UPN

查看:584
本文介绍了LDAP搜索与UPN Active Directory中的用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用LDAP身份验证,需要帮助

I am using LDAP Authentication, Need a help

假设我有一个用户(user1@zzservers.ad),其中zzservers.ad是demo.com域的UPN别名,我已经知道的方式按域搜索Active Directory中的用户。

Suppose i have a user(user1@zzservers.ad), where zzservers.ad is a UPN Alias of demo.com domain , i already know of a way to search a user in active directory by domain.

但没有人知道如何通过UPN别名搜索Active Directory中的用户。

But Does anyone know about how to search a user in active directory by UPN Alias.

其实,当用户user1@zzservers.ad登录到应用程序,我想知道,如果用户是present于公元,从而进一步进行认证。

Actually when user user1@zzservers.ad login into the application, i want to know if user is present in AD, so as to proceed authentication further.

任何帮助将是巨大的AP preciated。

Any help would be hugely appreciated.

感谢

推荐答案

这是更多的普通用户搜索:

This is more an ordinary user search:

public String findUserByUPN( LdapContext ctx, String username )
{
   // Domain name should be in DC=your,DC=domain,DC=com format
   String domain = "DC=demo,DC=com";
   String filter = "(userPrincipalName=" + username + ")" ;
   NamingEnumeration<SearchResult> results = ctx.search( domain, filter, null );
   while ( results.hasMore() )
   {
       SearchResult result = results.next();
       // If you get a result here, the user was found
       return result.getNameInNamespace();
   }
   return null;
}

这篇关于LDAP搜索与UPN Active Directory中的用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆