Groups > Asp .Net > ASP dotNET Security > Re: membership on remote server




membership on remote server

membership on remote server
Thu, 3 Apr 2008 02:26:06 +0000
I have been reading alot of the forum posts trying to solve my issue with using
membership and login controls on a remote webserver. Aside from trying to manage
memberships on the remote server, I am just trying to get my login wontrols to
work on a basic level. They work fine on my local development computer using
visual studio 2008. But, when I upload the the website and upload ASPNETDB.MDF
to the App_Data folder on the remote server, and then try to login, I get the
ever popular error:

An error has occurred while establishing a connection to the server.  When
connecting to SQL Server 2005, this failure may be caused by the fact that under
the default settings SQL Server does not allow remote connections. (provider:
SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

I do use a remote SQL Server 2005 database for the rest of the data on my
website and have read that I can use aspnet_regsql.exe to basically install the
membership schema to my SQL server DB, but I have also read that I need to do it
on a blank Database Instance. Will this erase the rest of my tables?

I have also read that ASPNETDB for memberships will only work on a development
machine. Can't I just upload my ASPNETDB.MDF database to the webserver and add a
connection string, in addition to the one for my SQL Server 2005 DB, so that it
somehow delegates membership duties to the ASPNETDB.MDF on the webserver?

I understand that there is another factor to keep in mind, and that is that the
machine.config file used sqlexpress as default. Trying to figure all this out.

Here is my webconfig file: 

<?xmlversion="1.0"?><configuration>

<configSections><sectionGroupname="system.web.extensions"type
="System.Web.Configuration.SystemWebExtensionsSectionGroup,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35">

<sectionGroupname="scripting"type="System.Web.Configuration.Sc
riptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35"><sectionname="scriptResourceHan
dler"type="System.Web.Configuration.ScriptingScriptResourceHandlerSect
ion, System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35"requirePermission="false"allowDef
inition="MachineToApplication"/>

<sectionGroupname="webServices"type="System.Web.Configuration.
ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0,
Culture=neutral,
PublicKeyToken=31BF3856AD364E35"><sectionname="jsonSerialization
"type="System.Web.Configuration.ScriptingJsonSerializationSection,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35"requirePermission="false"allowDef
inition="Everywhere"/>

<sectionname="profileService"type="System.Web.Configuration.Sc
riptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0,
Culture=neutral,
PublicKeyToken=31BF3856AD364E35"requirePermission="false"allowDef
inition="MachineToApplication"/><sectionname="authenticatio
nService"type="System.Web.Configuration.ScriptingAuthenticationService
Section, System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35"requirePermission="false"allowDef
inition="MachineToApplication"/>

<sectionname="roleService"type="System.Web.Configuration.Scrip
tingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35"requirePermission="false"allowDef
inition="MachineToApplication"/></sectionGroup>

</sectionGroup></sectionGroup>

</configSections><appSettings/>

<connectionStrings>

<addname="tceDatabaseOnlineSQLConnection"connectionString="Dat
a Source=sql2k512.discountasp.net;Initial Catalog=SQL2005_347405_tce;User
ID=SQL2005_347405_tce_user;Password=*******"providerName="System.Data.
SqlClient" />

</connectionStrings>

<system.web><roleManagerenabled="true" />

<customErrorsdefaultRedirect="~/error.aspx"
/><compilationdebug="true">

<assemblies><addassembly="System.Core, Version=3.5.0.0,
Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

<addassembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35"/><addassembly="System.Data.Data
SetExtensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=B77A5C561934E089"/>

<addassembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=B77A5C561934E089"/></assemblies>

</compilation><authenticationmode="Forms" />

pages><controls>

<addtagPrefix="asp"namespace="System.Web.UI"assembly=&quo
t;System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35"/><addtagPrefix="asp"namesp
ace="System.Web.UI.WebControls"assembly="System.Web.Extensions,
Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

</controls></pages>

<httpHandlers><removeverb="*"path="*.asmx"/>

<addverb="*"path="*.asmx"validate="false"type=&
quot;System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions,
Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35"/><addverb="*"path="*_
AppService.axd"validate="false"type="System.Web.Script.Servi
ces.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0,
Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

<addverb="GET,HEAD"path="ScriptResource.axd"type="Sy
stem.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0,
Culture=neutral,
PublicKeyToken=31BF3856AD364E35"validate="false"/></httpHan
dlers>

<httpModules><addname="ScriptModule"type="System.Web.Han
dlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35"/>

</httpModules></system.web>

<system.codedom><compilers>

<compilerlanguage="c#;cs;csharp"extension=".cs"warningLev
el="4"type="Microsoft.CSharp.CSharpCodeProvider, System,
Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089"><providerOptionname="CompilerVe
rsion"value="v3.5"/>

<providerOptionname="WarnAsError"value="false"/></c
ompiler>

<compilerlanguage="vb;vbs;visualbasic;vbscript"extension=".vb&
quot;warningLevel="4"type="Microsoft.VisualBasic.VBCodeProvider,
System, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089"><providerOptionname="CompilerVe
rsion"value="v3.5"/>

<providerOptionname="OptionInfer"value="true"/><pro
viderOptionname="WarnAsError"value="false"/>

</compiler></compilers>

</system.codedom>

<system.webServer><validationvalidateIntegratedModeConfiguration="
false"/>

<modules><removename="ScriptModule"/>

<addname="ScriptModule"preCondition="managedHandler"type=
"System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0,
Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></modules>

<handlers><removename="WebServiceHandlerFactory-Integrated"/&
gt;

<removename="ScriptHandlerFactory"/><removename="ScriptH
andlerFactoryAppServices"/>

<removename="ScriptResource"/><addname="ScriptHandlerFac
tory"verb="*"path="*.asmx"preCondition="integrated
Mode"type="System.Web.Script.Services.ScriptHandlerFactory,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35"/>

<addname="ScriptHandlerFactoryAppServices"verb="*"path=&q
uot;*_AppService.axd"preCondition="integratedMode"type="Syst
em.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions,
Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35"/><addname="ScriptResource"
preCondition="integratedMode"verb="GET,HEAD"path="Scrip
tResource.axd"type="System.Web.Handlers.ScriptResourceHandler,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35"/>

</handlers></system.webServer>

<runtime><assemblyBindingxmlns="urn:schemas-microsoft-com:asm.v1&q
uot;>

<dependentAssembly><assemblyIdentityname="System.Web.Extensions&qu
ot;publicKeyToken="31bf3856ad364e35"/>

<bindingRedirectoldVersion="1.0.0.0-1.1.0.0"newVersion="3.5.0.
0"/></dependentAssembly>

<dependentAssembly><assemblyIdentityname="System.Web.Extensions.De
sign"publicKeyToken="31bf3856ad364e35"/>

<bindingRedirectoldVersion="1.0.0.0-1.1.0.0"newVersion="3.5.0.
0"/></dependentAssembly>

</assemblyBinding></runtime>

<system.net><mailSettings>

<smtpfrom="info@alljesus.net"><networkhost="smtp.alljesu
s.net"password="******"userName="info@alljesus.net"
/>

</smtp></mailSettings>

</system.net>

</configuration>
Post Reply
Re: membership on remote server
Thu, 3 Apr 2008 04:22:19 +0000
In SQL Server Configuration Manager
 SQL Native Client Configuration Make sure Shared Memory Enabled,
TCP/IP enabled
Named Pipes Enabled

Double click TCP/IP and make sure the port number is 1433


Satalaj.
Post Reply
Re: membership on remote server
Thu, 3 Apr 2008 10:13:00 +0000
cantrall:I do use a remote SQL Server 2005 database for the rest of the data on
my website and have read that I can use aspnet_regsql.exe to basically install
the membership schema to my SQL server DB, but I have also read that I need to
do it on a blank Database Instance. Will this erase the rest of my tables?

I just tried on a SQL Server 2008 CTP DB and it worked fine.

I would suggest you make a backup before you try, but it seems that it works
fine
Post Reply
Re: membership on remote server
Thu, 3 Apr 2008 11:54:17 +0000
Thanks for being the brave one here. I backed up my Database, then ran
aspnet_regsql.exe to install the schema, and it worked fine, without deleting my
existing tables. Then I added another connection string, so that they are now:

<connectionStrings>

<removename="LocalSqlServer" />
<addname="LocalSqlServer"
        connectionString="Data Source=sql2k512.discountasp.net;Integrated
Security=false;Initial Catalog=SQL2005_347405_tce;
                                    User
ID=SQL2005_347405_tce_user;Password=*****************"
        providerName="System.Data.SqlClient" />
<addname="tceDatabaseOnlineSQLConnection"
        connectionString="Data Source=sql2k512.discountasp.net;Initial
Catalog=SQL2005_347405_tce;
                                    User
ID=SQL2005_347405_tce_user;Password=*****************"
        providerName="System.Data.SqlClient" />

</connectionStrings>

Now, not only can I store my membership/user data in my SQL server, but I can
also still use the ASP.NET configuration utility to manage them. That's pretty
damn cool. The only thing I need to remember is to upload the web.config files
from directories that have access rules applied to them.

I appreciate your help. however, I have another quandary. I added two roles:
admin and users. Then I attached some access rules to my admin directory. the
webconfig shows:

<authorization>
  <denyusers="?" />
  <allowroles="admin" />
  <denyroles="users" />
</authorization>

The logic here is to only allow admin roles into the admin directory. With this
configuration, it allows admin roles, but denies user roles and anonymous users.
However, when someone goes to the site and creates an account using the
CreateUserWizard, they can still get to the admin page before I assign them a
user role.

I tried adding <deny roles="*" /> to the above config, but that
just denied everyone. I figured it would cascade like CSS, but no. I can't seem
to find an access rule to deny users who havent been assigned a role yet. Or is
there a way to auto assign the role of user when someone creates an account on
the site using the CreateUserWizard. You can check it out here:
http://www.alljesus.net/us.aspx At the bottom of the page is a link to the
administration page. If you create a user, you will be able to get onto the
admin page. Any thoughts?
Post Reply
Re: membership on remote server
Thu, 3 Apr 2008 12:24:41 +0000
Oops, I found that answer here:
http://forums.asp.net/p/1226498/2202096.aspx#2202096

Do this within the CreateUserWizard.CreatedUser event handler like so: 

protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
{
	Roles.AddUserToRole(CreateUserWizard1.UserName, "user");
}

I just wish I knew of an easier way to deny all users other than admin to the
admin page, instead of doing this:

<authorization>

<denyusers="?" /><allowroles="admin" />

<denyroles="users" /><denyroles="guests" />

</authorization>

 

Or else everytime I add a new role, I have to change the access rules on all
directories that I do this.
Post Reply
about | contact