How do you manage asp.net SQL membership roles/use

2019-02-12 15:34发布

How do you setup an asp.net sql membership role/membership provider on a production machine? I'm trying to setup BlogEngine.NET and all the documentation says to use the ASP.NET Website Administration tool from Visual Studio but that isn't available on a production machine. Am I the first BlogEngine user to use it on a non-development box?

The SQL server is completely blocked off from everything but the production box, I do have SQL Management Studio on there though.

EDIT: I mean, how do you add new users/roles, not how do you create the tables. I've already ran aspnet_regsql to create the schema.

EDIT2: MyWSAT doesn't work because it requires an initial user in the database as well. I need an application that will allow me to create new users in the membership database without any authentication, just a connection string.

5条回答
我命由我不由天
2楼-- · 2019-02-12 16:10

You'll have to have .NET 2.0 installed on the machine, all the VS tool is is a GUI wrapper for a command line tool which is part of the framework.

Check C:\Windows\Microsoft.NET\Framework\v2.0.50727 for the app aspnet_regsql.exe

/? for command line switches, /W for a wizard mode

查看更多
啃猪蹄的小仙女
3楼-- · 2019-02-12 16:21

Solution 1 (standard, poor): Visual Studio -> Website menu -> ASP.NET Configuration.

Solution 2 (preffered): AspNetWSAT (easy to deploy, pretty powerfull)

查看更多
Luminary・发光体
4楼-- · 2019-02-12 16:26

I solved this problem by setting up a default super user at application start up.

By adding this to gobal.asax


    void Application_Start(object sender, EventArgs e) 
    {
        // Code that runs on application startup

        // check that the minimal security settings are created
        Security.SetupSecurity();
    }

Then in the security class:


using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

/// 
/// Creates minimum roles and user for application access.
/// 
public class Security
{
    // application roles
    public static string[] applicationRoles = 
        { "Roles1", "Roles2", "Roles3", "Roles4", "Roles5" };
    // super user
    private static string superUser = "super";
    // default password, should be changed on first connection
    private static string superUserPassword = "default";

    private Security()
    {
        //
        // TODO: Add constructor logic here
        //
    }

    /// 
    /// Creates minimal membership environment.
    /// 
    public static void SetupSecurity()
    {
        SetupRoles();
        SetupSuperuser();
    }

    /// 
    /// Checks roles, creates missing.
    /// 
    public static void SetupRoles()
    {
        // create roles
        for (int i = 0; i 
    /// Checks if superuser account is created.
    /// Creates the account and assigns it to all roles.
    /// 
    public static void SetupSuperuser()
    {
        // create super user
        MembershipUser user = Membership.GetUser(superUser);
        if (user == null)
            Membership.CreateUser(superUser, superUserPassword, "maintenance@acorel.com");

        // assign superuser to roles
        for (int i = 0; i 

Once you have a default user, you can use AspNetWSAT or other.

查看更多
一纸荒年 Trace。
5楼-- · 2019-02-12 16:33

Have you looked at the IIS capabilities to manage membership? Go to the ASP.NET tab on IIS of the production server and see if this may help you.

查看更多
做个烂人
6楼-- · 2019-02-12 16:35

The solution is simple, the WSAT tool is on the production machine, but it's unreachable, you can configure the site , and you can use it.

The WSAT tool with source code is located in your C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\ASP.NETWebAdminFiles folder. To make it accessible on the network, all you have to do is go to IIS–>Create new virtual directory–>Point to the above folder and remove anonymous access from directory settings page.

Then you need to access it the same way your local ASP.Net configuration tool is accessed i.e via a URL which resembles something like :http://SERVER/AdminTool/default.aspx?applicationPhysicalPath=C:\Inetpub\wwwrooot\testsite\&applicationUrl=/testsite

查看更多
登录 后发表回答