ActiveDirectoryMembershipProvider 用于验证用户
我想使用 ActiveDirectoryMembershipProvider 的 ValidateUser 方法来验证 AD 中是否存在用户。
我正在以表格形式输入用户名和密码。然后我想实例化提供程序并调用 ValidateUser
<add name="AspNetActiveDirectoryMembershipProvider"
type="System.Web.Security.ActiveDirectoryMembershipProvider"
connectionStringName="ADConnection"
attributeMapUsername = "userPrincipalName" />
我只是将实际值替换为帖子的测试。
<add name="ADConnection" connectionString="LDAP://test.test.test.com/dc=test,dc=com" />
为了做我想做的事情,我是否需要向提供程序提供用户名和密码所以它可以首先连接,即系统帐户..一旦建立,我就可以检查我想要验证的用户?
谢谢, J
I would like to use the ValidateUser
method of the ActiveDirectoryMembershipProvider to validate that a user exists in AD.
I am taking in the username and password in a form. I would like to then instantiate the provider and call ValidateUser
<add name="AspNetActiveDirectoryMembershipProvider"
type="System.Web.Security.ActiveDirectoryMembershipProvider"
connectionStringName="ADConnection"
attributeMapUsername = "userPrincipalName" />
I just replace real values with test for the post..
<add name="ADConnection" connectionString="LDAP://test.test.test.com/dc=test,dc=com" />
To do what I want to do, do i need to provide a username and password to the provider so it can connect in first place, i.e. a system account.. and once its established I can then check the user I want to validate?
Thanks,
J
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 ASP.NET 会员系统,重点是您不需要实例化提供程序类或任何其他内容 - 您定义的提供程序类可立即在
Membership
静态实例下使用。因此,在您的情况下,只需确保配置正确,然后执行以下操作:
Membership
将是您定义的必要类 - 只需调用其静态方法即可完成! :-)更新: 看来您应该能够按照这些方式轻松实例化多个会员资格提供程序:
所以基本上,您可以通过
Membership.Providers[ 访问它来获取特定的会员资格提供程序"FabrikamSqlProvider"]
,然后调用其方法,例如.ValidateUser()
。基本的
Membership.ValidateUser
将仅使用您定义为默认的成员资格提供程序 - 但这不会阻止您使用其他提供程序!With the ASP.NET membership system, the whole point is you don't need to instantiate a provider class or anything - the one you've defined is available right away under the
Membership
static instance.So in your case, just make sure the config is correct, and then do something like:
The
Membership
will be the necessary class you've defined - just call the static methods on it and be done with it! :-)Update: it appears you should be able to easily instantiate multiple membership providers along those lines here:
So basically, you can get a specific membership provider by accessing it through
Membership.Providers["FabrikamSqlProvider"]
and then call methods on it, like.ValidateUser()
.The basic
Membership.ValidateUser
will simply use the membership provider you've defined as the default - but it doesn't stop you from using others!