开发者

Java LDAP password authentication

开发者 https://www.devze.com 2023-01-05 15:07 出处:网络
The below search term seems to return match if a user simply exists in the active directory: NamingEnumeration<SearchResult> ne = dirContext.search(

The below search term seems to return match if a user simply exists in the active directory:

NamingEnumeration<SearchResult> ne = dirContext.search(
                        baseDN,
                        userO开发者_Go百科bjectQuery,
                        new String[] { userName },
                        SearchControls)

The userObjectQuery is like userObjectQuery=(&(sAMAccountName=%u)(objectclass=user))

Where %u above will be substituted by the username.

How do I make sure that the users password also matches and only then return true?


Once you find the user using your search code, you can get the user's full DN with getNameInNamespace()

Then you can bind as that full DN and password to authenticate.

0

精彩评论

暂无评论...
验证码 换一张
取 消