简体   繁体   中英

AD Authentication Unknown username or bad password

I am using VS2005 C#.

I am trying to switch my login authentication from the ASP.NET Web Site Administration Tool from using Internet to Local Network , which is the Windows authentication.

I have set the MembershipProvider of my Login tool in my web form to my MP name, MyADMembershipProvider .

Below is my current web.config file after making some changes:

<configuration>
    <appSettings/>
    <connectionStrings>
        <add name="SODConnectionString" connectionString="CONNECTIONSTRING" providerName="System.Data.SqlClient"/>

        <add name="ADConnectionString" connectionString="LDAP://URL"/>
    </connectionStrings>
    <system.web>
        <authentication mode="Windows" />
    <roleManager enabled="true" />
    <pages styleSheetTheme="DataWebControls"/>
        <membership defaultProvider="MyADMembershipProvider">
            <providers>
                <clear/>
                <add name="MyADMembershipProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=PUBTOKEN" applicationName="SOD" connectionStringName="ADConnectionString" connectionUsername="domain\Username" connectionPassword="Password" attributeMapUsername="sAMAccountName" enableSearchMethods="true" />
            </providers>

        </membership>
        <siteMap defaultProvider="XmlSiteMapProvider" enabled="true">
            <providers>
                <add name="XmlSiteMapProvider"
      description="Default SiteMap provider."
      type="System.Web.XmlSiteMapProvider"
      siteMapFile="Web.sitemap"
      securityTrimmingEnabled="true" />
            </providers>
        </siteMap>
            <compilation debug="true"/>
            <!-- Turn on Custom Errors -->
        <customErrors defaultRedirect="~/Error/NetworkError.aspx" mode="On">
   <error statusCode="404" redirect="~/Error/PageNotFound.aspx" />
  </customErrors>
    </system.web>
</configuration>`

I am currently receiving a configuration parse error message: Logon failure: unknown user name or bad password when I tried to log on with my Windows credentials of my machine within the intranet.

The error pointed out line

<add name="MyADMembershipProvider" 
     type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" 
     applicationName="SOD" 
     connectionStringName="ADConnectionString" 
     connectionUsername="domain\Username" 
     connectionPassword="Password" 
     attributeMapUsername="sAMAccountName" 
     enableSearchMethods="true" />

has an error.

May I know which part of my code went wrong?


EDIT:

I have filled in the actual credentials for the code

connectionUsername="domain\Username" connectionPassword="Password"

I am now able to login with the correct credentials, and I am also prompted wrong credential for incorrect log in attempts.

When another user of different credential from the one I 'hardcoded' in the connectionUsername and connectionPassword , the user is still able to log on.

However, my LoginName tool from the toolbox still shows the username of the 'hardcoded' credentials in the connectionUsername instead of the username of the logged in user.

May I know why is it so?

I believe the error is with the membership provider and not specifically with the logon.

It looks to me that the connectionUsername and connectionPassword properties in the membership provider are not specifying a valid AD account. I believe this account is used to verify the credentials during the logon process and to retrieve information about the account once it is logged on.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM