“DirectoryOperationException:请求中的值无效” LDAP 绑定时为一个用户抛出此错误
我正在使用 System.DirectoryServices.Protocols.LDAP 对 Oracle/Sun LDAP 服务器进行身份验证。该代码通常工作正常,但对于极少数用户,我收到以下异常:
System.DirectoryServices.Protocols.DirectoryOperationException:请求中的值无效。 在 System.DirectoryServices.Protocols.LdapConnection.BindHelper(NetworkCredential newCredential, Boolean needSetCredential)
以下是我遵循的一般算法:
- 建立与 ldap 服务器的连接。 AuthType 为 Basic,AutoBind 已禁用,LDAP 版本 3。
- 我使用“浏览器”用户名和密码进行绑定(专门创建的帐户,以便我的程序可以检索有关用户的信息)。即使身份验证失败,我也需要检索他们的信息,因此我无法立即绑定为用户。
- 检索有关用户的信息。
- 调用 connection.Bind(new NetworkCredential(USERDN, USERPASS)) 使用用户的凭据重新绑定。这适用于我 99% 以上的用户群。我通常会查找带有“提供的凭据无效”消息的 DirectoryException。判断凭据是否正确。但是,对于少数用户,我收到“请求中的值无效”异常。
每次尝试进行身份验证时,少数帐户都会引发此异常,因此这似乎不是服务器的一次性问题。
I'm using System.DirectoryServices.Protocols.LDAP to authenticate against an Oracle/Sun LDAP server. The code normally works fine, but for a very small number of users, I'm getting the following exception:
System.DirectoryServices.Protocols.DirectoryOperationException: A value in the request is invalid.
at System.DirectoryServices.Protocols.LdapConnection.BindHelper(NetworkCredential newCredential, Boolean needSetCredential)
Here's the general algorithm that I'm following:
- Establish a connection to the ldap server. AuthType is Basic, AutoBind is disabled, LDAP Version 3.
- I bind using a "browser" username and password (an account created specifically so my program can retrieve information about users). I need to retrieve their information even if authentication fails, so I can't bind as the user right away.
- Retrieve information about the user.
- Call connection.Bind(new NetworkCredential(USERDN, USERPASS)) to re-bind using the user's credentuials. This works for over 99% of my userbase. I normally look for a DirectoryException with a message of "The supplied credential is invalid." to tell if the credentials were correct or not. However, with a few users, I get the "A value in the request is invalid" exception.
This exception is thrown for the handful of accounts every time they attempt to authenticate, so it doesn't seem to be a one time issue with the server.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论