如何在生产管理asp.net SQL成员资格角色/用户? [英] How do you manage asp.net SQL membership roles/users in production?

查看:342
本文介绍了如何在生产管理asp.net SQL成员资格角色/用户?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你怎么安装在生产机器上一个asp.net SQL成员角色/成员资格提供?我试图安装BlogEngine.NET,所有的文件说,使用从Visual Studio中的ASP.NET网站管理工具,但不可用在生产机器上。我是第一个BlogEngine用户使用它放在一个非开发中?

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?

SQL服务器完全的一切,但在生产中挡着,我确实有SQL Management Studio中在那里虽然。

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

编辑:我的意思是,你怎么添加新用户/角色,而不是你如何创建表。我已经跑了aspnet_regsql创建模式。

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不起作用,因为它需要在数据库中的初始用户也是如此。我需要一个应用程序,让我创造了会员数据库的新用户无需任何身份验证,只是一个连接字符串。

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.

推荐答案

我解决了这个问题,通过设置在应用程序中默认的超级用户启动。

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

通过添加这gobal.asax

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 

一旦你有一个默认的用户,可以使用AspNetWSAT或其他。

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

这篇关于如何在生产管理asp.net SQL成员资格角色/用户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆