<tfoot id='iWb5X'></tfoot>
    1. <legend id='iWb5X'><style id='iWb5X'><dir id='iWb5X'><q id='iWb5X'></q></dir></style></legend>

        <bdo id='iWb5X'></bdo><ul id='iWb5X'></ul>

      <small id='iWb5X'></small><noframes id='iWb5X'>

      1. <i id='iWb5X'><tr id='iWb5X'><dt id='iWb5X'><q id='iWb5X'><span id='iWb5X'><b id='iWb5X'><form id='iWb5X'><ins id='iWb5X'></ins><ul id='iWb5X'></ul><sub id='iWb5X'></sub></form><legend id='iWb5X'></legend><bdo id='iWb5X'><pre id='iWb5X'><center id='iWb5X'></center></pre></bdo></b><th id='iWb5X'></th></span></q></dt></tr></i><div id='iWb5X'><tfoot id='iWb5X'></tfoot><dl id='iWb5X'><fieldset id='iWb5X'></fieldset></dl></div>
      2. ActiveDirectoryMembershipProvider 验证用户

        时间:2023-10-24
        <legend id='q3N1V'><style id='q3N1V'><dir id='q3N1V'><q id='q3N1V'></q></dir></style></legend>
          1. <i id='q3N1V'><tr id='q3N1V'><dt id='q3N1V'><q id='q3N1V'><span id='q3N1V'><b id='q3N1V'><form id='q3N1V'><ins id='q3N1V'></ins><ul id='q3N1V'></ul><sub id='q3N1V'></sub></form><legend id='q3N1V'></legend><bdo id='q3N1V'><pre id='q3N1V'><center id='q3N1V'></center></pre></bdo></b><th id='q3N1V'></th></span></q></dt></tr></i><div id='q3N1V'><tfoot id='q3N1V'></tfoot><dl id='q3N1V'><fieldset id='q3N1V'></fieldset></dl></div>
              <tbody id='q3N1V'></tbody>
          2. <tfoot id='q3N1V'></tfoot>

            • <bdo id='q3N1V'></bdo><ul id='q3N1V'></ul>

                  <small id='q3N1V'></small><noframes id='q3N1V'>

                  本文介绍了ActiveDirectoryMembershipProvider 验证用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想使用 ActiveDirectoryMembershipProvider 的 ValidateUser 方法来验证用户是否存在于 AD 中.

                  I would like to use the ValidateUser method of the ActiveDirectoryMembershipProvider to validate that a user exists in AD.

                  我正在以表格形式输入用户名和密码.然后我想实例化提供者并调用 ValidateUser

                  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?

                  谢谢,J

                  推荐答案

                  使用 ASP.NET 成员系统,重点是您不需要实例化提供程序类或任何东西 - 您定义的提供程序类可用立即在 Membership 静态实例下.

                  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:

                   if (Membership.ValidateUser(UsernameTextbox.Text, PasswordTextbox.Text))
                       FormsAuthentication.RedirectFromLoginPage(UsernameTextbox.Text, NotPublicCheckBox.Checked);
                   else
                       Msg.Text = "Login failed. Please check your user name and password and try again.";
                  

                  Membership 将是您定义的必要类 - 只需调用它的静态方法并完成它!:-)

                  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:

                      if (e.UserName.IndexOf("@contoso.com") >= 0)
                      {
                          e.Authenticated = Membership.Providers["ContosoSqlProvider"].ValidateUser(e.UserName, e.Password);
                      }
                      else if (e.UserName.IndexOf("@fabrikam.com") >= 0)
                      {
                          e.Authenticated = Membership.Providers["FabrikamSqlProvider"].ValidateUser(e.UserName, e.Password);
                      }
                      else
                      {
                          e.Authenticated = Membership.Provider.ValidateUser(e.UserName, e.Password);
                      }
                  

                  所以基本上,您可以通过 Membership.Providers["FabrikamSqlProvider"] 访问特定的会员提供程序,然后在其上调用方法,例如 .ValidateUser().

                  So basically, you can get a specific membership provider by accessing it through Membership.Providers["FabrikamSqlProvider"] and then call methods on it, like .ValidateUser().

                  基本的 Membership.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!

                  这篇关于ActiveDirectoryMembershipProvider 验证用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Active Directory 中联机的计算机列表 下一篇:在 C# 中,如何访问 Active Directory 以获取某个用户所属的组列表?

                  相关文章

                  <tfoot id='5GXsm'></tfoot>

                  <small id='5GXsm'></small><noframes id='5GXsm'>

                  1. <i id='5GXsm'><tr id='5GXsm'><dt id='5GXsm'><q id='5GXsm'><span id='5GXsm'><b id='5GXsm'><form id='5GXsm'><ins id='5GXsm'></ins><ul id='5GXsm'></ul><sub id='5GXsm'></sub></form><legend id='5GXsm'></legend><bdo id='5GXsm'><pre id='5GXsm'><center id='5GXsm'></center></pre></bdo></b><th id='5GXsm'></th></span></q></dt></tr></i><div id='5GXsm'><tfoot id='5GXsm'></tfoot><dl id='5GXsm'><fieldset id='5GXsm'></fieldset></dl></div>

                    1. <legend id='5GXsm'><style id='5GXsm'><dir id='5GXsm'><q id='5GXsm'></q></dir></style></legend>

                      • <bdo id='5GXsm'></bdo><ul id='5GXsm'></ul>