Error while adding a sql and a AD prvider in web.config

  • Thread starter Thread starter siddharthkhare
  • Start date Start date
S

siddharthkhare

Hi All,
can some one please help me with this.......

As soon as i start my application ASP.net throws and error while
reading the providers from config file.
I am trying to add a sql and a AD provider.
If i comment out the AD provider part all works fine.

<?xml version="1.0"?>

<configuration>

<connectionStrings>


<add name="SqlServices" providerName="System.Data.SqlClient"
connectionString="workstation id='Some work Station';packet
size=4096;user id=SomeUser;data source=SOME;persist security
info=True;initial catalog=SOME;password=SOME"/>

<add name="ADConnectionString" connectionString="LDAP://SomeLDAP
PAth" />


</connectionStrings>

<appSettings/>
<!-- <connectionStrings/> -->

<system.web>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<compilation debug="true">

</compilation>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Windows" />
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.

<customErrors mode="RemoteOnly"
defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
-->

<roleManager defaultProvider="SqlProvider1"
enabled="true"
cacheRolesInCookie="true"
cookieName=".ASPROLES"
cookieTimeout="30"
cookiePath="/"
cookieRequireSSL="false"
cookieSlidingExpiration="true"
cookieProtection="All" >
<providers>
<add
name="SqlProvider1"
type="System.Web.Security.SqlRoleProvider"
connectionStringName="SqlServices"
applicationName="SampleApplication" />
</providers>
</roleManager>
<membership defaultProvider="SqlProvider1"
userIsOnlineTimeWindow="15">
<providers>
<clear />
<add
name="SqlProvider1"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="SqlServices"
applicationName="MyApplication"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
requiresUniqueEmail="false"
passwordFormat="Hashed"
minRequiredPasswordLength="3"
minRequiredNonalphanumericCharacters="0"/>

<add name="MyADMembershipProvider"
type="System.Web.Security.ActiveDirectoryMembershipProvider,
System.Web, Version=2.0.0.0,Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="ADConnectionString"
connectionUsername="SomeUserName" connectionPassword="SomePassword"/
</providers>
</membership>
<profile defaultProvider="SqlProvider1">
<providers>
<clear />
<add name="SqlProvider"
type="System.Web.Profile.SqlProfileProvider"
connectionStringName="SqlServices"
applicationName="SampleApplication"
description="SqlProfileProvider for SampleApplication" /</providers>
</profile>

</system.web>

</configuration>


Thanks
Siddharth
 
Hi All,
can some one  please help me with this.......

As soon as i start my application ASP.net throws and error while
reading the providers from config file.
I am trying to add a sql and a AD provider.
If i comment out the AD provider part all works fine.

<?xml version="1.0"?>

<configuration>

  <connectionStrings>

    <add name="SqlServices" providerName="System.Data.SqlClient"
connectionString="workstation id='Some work Station';packet
size=4096;user id=SomeUser;data source=SOME;persist security
info=True;initial catalog=SOME;password=SOME"/>

    <add name="ADConnectionString" connectionString="LDAP://SomeLDAP
PAth" />

  </connectionStrings>

    <appSettings/>
   <!-- <connectionStrings/>  -->

    <system.web>
        <!--
            Set compilation debug="true" to insert debugging
            symbols into the compiled page. Because this
            affects performance, set this value to true only
            during development.
        -->
        <compilation debug="true">

        </compilation>
        <!--
            The <authentication> section enables configuration
            of the security authentication mode used by
            ASP.NET to identify an incoming user.
        -->
        <authentication mode="Windows" />
        <!--
            The <customErrors> section enables configuration
            of what to do if/when an unhandled error occurs
            during the execution of a request. Specifically,
            it enables developers to configure html error pages
            to be displayed in place of a error stack trace.

        <customErrors mode="RemoteOnly"
defaultRedirect="GenericErrorPage.htm">
            <error statusCode="403" redirect="NoAccess.htm" />
            <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>
        -->

      <roleManager defaultProvider="SqlProvider1"
            enabled="true"
            cacheRolesInCookie="true"
            cookieName=".ASPROLES"
            cookieTimeout="30"
            cookiePath="/"
            cookieRequireSSL="false"
            cookieSlidingExpiration="true"
            cookieProtection="All" >
        <providers>
          <add
            name="SqlProvider1"
            type="System.Web.Security.SqlRoleProvider"
            connectionStringName="SqlServices"
            applicationName="SampleApplication" />
        </providers>
      </roleManager>
      <membership defaultProvider="SqlProvider1"
userIsOnlineTimeWindow="15">
        <providers>
          <clear />
          <add
            name="SqlProvider1"
            type="System.Web.Security.SqlMembershipProvider"
            connectionStringName="SqlServices"
            applicationName="MyApplication"
            enablePasswordRetrieval="false"
            enablePasswordReset="true"
            requiresQuestionAndAnswer="false"
            requiresUniqueEmail="false"
            passwordFormat="Hashed"
            minRequiredPasswordLength="3"
            minRequiredNonalphanumericCharacters="0"/>

          <add name="MyADMembershipProvider"
type="System.Web.Security.ActiveDirectoryMembershipProvider,
System.Web, Version=2.0.0.0,Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="ADConnectionString"
connectionUsername="SomeUserName" connectionPassword="SomePassword"/



        </providers>
      </membership>
      <profile defaultProvider="SqlProvider1">
        <providers>
          <clear />
          <add name="SqlProvider"
               type="System.Web.Profile.SqlProfileProvider"
               connectionStringName="SqlServices"
               applicationName="SampleApplication"
               description="SqlProfileProvider for SampleApplication" /

        </providers>
      </profile>

    </system.web>

</configuration>

Thanks
Siddharth

ActiveDirectoryMembershipProvider uses an Active Directory or ADAM,
SqlMembershipProvider uses a SQL Server user store. Do you mean you
need to use both in the same time?

http://msdn.microsoft.com/en-us/library/ms998347.aspx
 
yes. i am writing a common reusable web service that will do
authentication and authorization.

some consumers of this web service will use sql authentication and
some might use AD.

i need to be able to programticaly pick the right provider depending
upon what consumer of the this web service wants i.e authenticate
agagin sql or AD.
Thanks
Siddharth
 
two questions..
1. is it possible to add amultiple Ad and multiple sql provider in
memebership section within same web.config file?
2.I tried just by adding only one AD provider in the web.config file
that I have posted above and that also failed. this time i had removed
sql provider.So makes me think could it be be that when .net reads
providers it validates them also such as LDAP path etc.. and may be
that is wrong or i don't reuired permissons etc...could that be
causing it.
Thanks
siddharth
 
Back
Top