Reading feeds By default, you can only use a native instance of Visual Studio 2005 to manage security credentials in a SQL Server database that is published with ASP.net 2.0. This article will show you how to use a Web service to wrap a asp.net 2.0 provider and expand this management capability by using a Windows Form application to manage the voucher store.
Today, both the Internet and intranet programs generally require a customized way to store and manage user accounts and roles. To this end, ASP.net 2.0 provides a ready-made provider model and a SQL sever database. Unfortunately, this credential database can only be managed through visual Studio 2005来 and only for native Web applications. This is no doubt very inconvenient and not widely used.
This article describes a fully customizable security management application that a super user can use. The application wraps and adds functionality to the ASP.net 2.0 provider by using a Web service. This article describes in detail the design approach, the problems faced and the technologies included in the application. It also introduces some useful and powerful technologies, such as web-based Web services, reflective Web service compatibility, Advanced C # 2.0 programming, Web Services security, and Web service transactions.
First, ASP.net 2.0 certificate infrastructure
internet-based applications often do not rely on Windows accounts and groups, but rely on form-based authentication and combine some sort of background custom voucher store, such as SQL Server. To help developers avoid duplication of design and build such solutions, a ready-made security credential infrastructure is added to the ASP.net 2.0 release. The ASP.net 2.0 credential store is not only available for asp.net applications, but it can be used by ASP.net Web services and Windows Form applications to manage their user credentials. In addition, the Windows communication base (encoded as indigo) service can also be easily set up to use the ASP.net 2.0 security voucher store.
ASP.net 2.0 uses a provider model to access and manage credentials to avoid coupling applications to any particular storage. This application is developed by programmers while leveraging the advantages of the abstract provider model. A superuser is responsible for selecting and managing a particular credential store. Figure 1 shows the architecture of the ASP.net 2.0 security provider.
Figure 1. ASP.net 2.0 security provider model
Membership provider is responsible for managing users, while role provider is responsible for managing roles. In the voucher store, each user or role is limited to one application. This allows different applications to use the same credential store without conflict with each other's user name or role. Asp. NET provides support for credential stores such as SQL Server, Windows, and active directories (see Figure 1). In order to install the SQL Server voucher database, you can run the Aspnet_regsql.exe program at the following location:
\microsoft.net\framework\
This installer creates a new database called ASPNETDB-it contains tables, users, roles for a set of applications, and stored procedures to access those tables. This SQL Server database is carefully designed using the latest security technologies. In addition, ASP.net 2.0 provides a set of classes corresponding to the provider (Figure 1).
Information about which provider is used is saved in the application's configuration file (app.config or web.config). You hardly need to interact directly with a particular provider; instead, there are two static helper classes: Membership and roles-They are responsible for reading from the configuration file which provider to use. The default provider (that is, when no provider is specified) is SQL Server. The Membership Class (Listing 1) allows you to create and delete users, retrieve information about users, and view password policies.
List 1:membership Assistant class
[Serializable]
public class membershipuser{
Public virtual bool ChangePassword (string OldPassword, String newpassword);
Public virtual string GetPassword (string passwordanswer);
Public virtual String ResetPassword (string passwordanswer);
Public virtual bool Unlockuser ();
//other members
}
public static class membership{
public static string Applicationname{get;set
public static MembershipUser CreateUser (string Username, string password);
public static MembershipUser CreateUser (string username,
string password, string email, string passwordquesti On,
string passwordanswer, bool isapproved, out membershipcreatestatus status);
public static bool DeleteUser (string Username,bool deleteallrelateddata);
public static MembershipUser GetUser (string username);
public static void UpdateUser (MembershipUser user);
public static bool ValidateUser (string username,string password);
public static boolEnablepasswordreset{get;}
public static bool Enablepasswordretrieval{get;}
//other members
}