Solved

Remote Membership

Posted on 2006-11-21
4
375 Views
Last Modified: 2008-01-09
The help of an Expert is needed. As you will see in the code provided below, from my web.config file, the membership database is an ASPNETDB.MDF file in the local App_Data folder. I'd like an Expert to show me what this page would look like if it were pointing to a remote SQL Server 2005 database instead. Please, no hyperlinks. I can do a google search myself. If you know how to do this, please show me; else, no worries, I'll figure it out myself.
Many kind thanks in advance!

<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
      <system.web>
            <authentication mode="Forms"/>
            <membership defaultProvider="CustomizedProvider">
                  <providers>
                        <add name="CustomizedProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="LocalSqlServer" applicationName="/" minRequiredPasswordLength="5" minRequiredNonalphanumericCharacters="0"/>
                  </providers>
            </membership>
            <compilation debug="true"/></system.web>
</configuration>
0
Comment
Question by:John Account
  • 2
  • 2
4 Comments
 
LVL 9

Expert Comment

by:kraffay
ID: 17988574
It would look the same, except the connectionStringName would say something like "RemoteSQLServer" and you would have a connection string node

      <connectionStrings>
            <add name="RemoteSQLServer" connectionString ="server=MyRemoteServer;uid=;pwd=;Trusted_Connection=yes;database=cs" />
      </connectionStrings>
0
 

Author Comment

by:John Account
ID: 17989629
So I added this below, but get this error: Unrecognized element 'connectionStrings'.
<membership defaultProvider="CustomizedProvider">
                  <providers>
                        <add name="CustomizedProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="RemoteSQLServer" applicationName="/" minRequiredPasswordLength="5" minRequiredNonalphanumericCharacters="0"/>
                  </providers>
      <connectionStrings>
      <add name="RemoteSQLServer" connectionString="Data Source=blahblah.com;Persist Security Info=True;User ID=admin;Password=blahblah;Trusted_Connection=yes;database=cs" />
      </connectionStrings>
            </membership>
0
 
LVL 9

Accepted Solution

by:
kraffay earned 500 total points
ID: 17989669
The web.config has a specific structure.  Here is a sample of one from CommunityServer (you'll need to put your connection string in the proper node, under the configuation node.):

<configuration>

      <connectionStrings>
            <add name="SiteSqlServer" connectionString ="server=.\SQLExpress;uid=;pwd=;Trusted_Connection=yes;database=cs" />
      </connectionStrings>

      <system.web>

            <!-- Standard Application Settings -->
            <compilation defaultLanguage="c#" debug="false" />

            <trace enabled="false" requestLimit="40" localOnly="true"/>
            <sessionState mode="Off" />

            <!-- Permit detailed errors to be displayed for remote clients -->
            <customErrors mode="RemoteOnly" defaultRedirect="~/error.htm">
                  <error statusCode="404" redirect="~/error-notfound.aspx" />
            </customErrors>


            <!-- START - CommunityServer specific application settings here -->
            <httpModules>
                  <add name="CommunityServer" type="CommunityServer.CSHttpModule, CommunityServer.Components" />
                  <!-- <add name="CSReporting" type="CommunityServer.Reporting.ReportingHttpModule, CommunityServer.Reporting" /> -->
            </httpModules>

            <httpHandlers>
                  <add verb="GET" path="Utility/redirect.aspx" type="CommunityServer.Components.Redirect, CommunityServer.Components" />
                  <add verb="GET" path="aggbug.aspx" type="CommunityServer.Components.HttpHandler.AggBugHandler, CommunityServer.Components" />
                  <add verb="GET" path="avatar.aspx" type="CommunityServer.Components.HttpHandler.AvatarHttpHandler, CommunityServer.Components" />
                  <add verb="GET" path="vcard.aspx" type="CommunityServer.Components.HttpHandler.VCardHttpHandler, CommunityServer.Components" />
                  <add verb="GET" path="r.ashx" type="CommunityServer.Components.HttpHandler.TinyUrlHttpHandler, CommunityServer.Components" />
            </httpHandlers>

            <!--
            authentication :
                  To use Windows Authentication, you must turn off Anonymous authentication in IIS
                  or IIS will never pass the user credentials to the forums.  

                  To enable Windows Authentication, simply comment out the forms authentication section
                  below and uncomment the Windows Authentication stuff.

                  To use the CookieAuthentication add-on module, set the authentication mode to "None" and
                  comment out the forms element.
            -->
            <authentication mode="Forms">
                  <forms name=".CommunityServer" protection="All" timeout="60000" loginUrl="login.aspx" slidingExpiration="true" />
            </authentication>

            <membership userIsOnlineTimeWindow="15" defaultProvider="CommunityServerSqlProvider" >
                  <providers>
                        <clear />
                        <add
                              name="CommunityServerSqlProvider"                  
                              type="CommunityServer.ASPNet20MemberRole.CSMembershipProvider, CommunityServer.ASPNet20MemberRole"
                              connectionStringName="SiteSqlServer"
                              enablePasswordRetrieval="false"
                              enablePasswordReset="true"
                              requiresQuestionAndAnswer="false"
                              requiresUniqueEmail="true"
                              passwordFormat="Hashed"
                              applicationName="dev"
                              description="Stores and retrieves membership data from the local Microsoft SQL Server database"
                              maxInvalidPasswordAttempts = "999"
                              passwordAttemptWindow = "999"
                              minRequiredPasswordLength = "6"
                              minRequiredNonalphanumericCharacters = "0"
                        />
                  </providers>
            </membership>

            <roleManager defaultProvider="CommunityServerSqlProvider" enabled="true"
                  cacheRolesInCookie="true" cookieName=".CSRoles" cookieTimeout="60000"
                  cookiePath="/"  cookieRequireSSL="false" cookieSlidingExpiration="true"
                  createPersistentCookie="true" cookieProtection="All" maxCachedResults="1000" >
                  <providers>
                        <clear />
                        <add
                              name="CommunityServerSqlProvider"
                              type="CommunityServer.ASPNet20MemberRole.CSRoleProvider, CommunityServer.ASPNet20MemberRole"
                              connectionStringName="SiteSqlServer"
                              applicationName="dev"
                              description="Stores and retrieves roles data from the local Microsoft SQL Server database"
                        />
                  </providers>
            </roleManager>

            <profile defaultProvider="CommunityServerSqlProvider" enabled="true" >
                  <providers>
                        <clear />
                        <add  
                              name="CommunityServerSqlProvider"  
                              type="CommunityServer.ASPNet20MemberRole.CSProfileProvider, CommunityServer.ASPNet20MemberRole"
                              connectionStringName="SiteSqlServer"
                              applicationName="dev"
                                  description="Stores and retrieves profile data from the local Microsoft SQL Server database"
                        />
                  </providers>

                  <properties>
                        <add name = "commonName" type = "string" />
                        <add name = "birthdate" type = "DateTime" />
                        <add name = "gender" type = "int" defaultValue = "0" />
                        <add name = "dateFormat" type = "string" defaultValue="MM-dd-yyyy" />
                        <add name = "publicEmail" type = "string" />
                        <add name = "language" type = "string" />
                        <add name = "webAddress" type = "string" />
                        <add name = "webLog" type = "string" />
                        <add name = "webGallery" type = "string" />
                        <add name = "signature" type = "string" />
                        <add name = "signatureFormatted" type = "string" />
                        <add name = "location" type = "string" />
                        <add name = "occupation" type = "string" />
                        <add name = "interests" type = "string" />
                        <add name = "msnIM" type = "string" />
                        <add name = "yahooIM" type = "string" />
                        <add name = "aolIM" type = "string" />
                        <add name = "icqIM" type = "string" />
                        <add name = "enablePostPreviewPopup" type = "System.Boolean" defaultValue = "false" />
                        <add name = "enableEmoticons" type = "System.Boolean" defaultValue = "true" />
                        <add name = "timezone" type = "System.Double" defaultValue="0" />
                        <add name = "fontsize" type = "int" defaultValue = "0" />
                        <add name = "bio" type = "string" />
                  </properties>
            </profile>

            <!--
            ========================
            Anonymous Identification
            ========================
            anonymousIdentification configuration:
                  enabled="[true|false]"                            Feature is enabled?
                      cookieName=".ASPXANONYMOUS"                       Cookie Name
                      cookieTimeout="100000"                            Cookie Timeout in minutes
                      cookiePath="/"                                    Cookie Path
                      cookieRequireSSL="[true|false]"                   Set Secure bit in Cookie
                      cookieSlidingExpiration="[true|false]"            Reissue expiring cookies?
                      cookieProtection="[None|Validation|Encryption|All]"    How to protect cookies from being read/tampered
                      domain="[domain]"                                 Enables output of the "domain" cookie attribute set to the specified value
              -->
            <anonymousIdentification
            enabled="false"
            cookieName=".ASPXANONYMOUS"
            cookieTimeout="100000"
                        cookiePath="/"
            cookieRequireSSL="false"
            cookieSlidingExpiration="true"
                        cookieProtection="None" domain="" />
      
      </system.web>

      <location path="EditPost.aspx">
            <system.web>
                  <authorization>
                        <deny users="?" />
                  </authorization>
            </system.web>
      </location>

      <location path="PrivateMessage.aspx">
            <system.web>
                  <authorization>
                        <deny users="?" />
                  </authorization>
            </system.web>
      </location>

      <location path="Download.aspx">
            <system.web>
                  <authorization>
                        <deny users="?" />
                  </authorization>
            </system.web>
      </location>

      <location path="License.aspx">
            <system.web>
                  <authorization>
                        <deny users="?" />
                  </authorization>
            </system.web>
      </location>

</configuration>
0
 

Author Comment

by:John Account
ID: 17989929
Whoah...that was a bit overwhelming at first, but I did manage to sort through all the excess, and finally get something working after repeated trial-and-error. Hopefully, soon I'll be ready to learn all that other stuff; just too busy now for it all, though. So thanks, kraffay, for coming through for me. Your help was greatly appreciated.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now