繁体中文
设为首页
加入收藏
当前位置:.Net技术首页 >> Asp.Net开发 >> Online CPU Console using a Web Control Library with .NET Security(3)

Online CPU Console using a Web Control Library with .NET Security(3)

2007-06-15 08:00:00  作者:  来源:互联网  浏览次数:0  文字大小:【】【】【
简介:Call the event viewer control by the tag prefix colon and the class name of eventlog.cs. Note that we set a property from the query string in the code behind file. Display vw_EventLog.ASPx file < ...

Call the event viewer control by the tag prefix colon and the class name of eventlog.cs. Note that we set a property from the query string in the code behind file.

Display vw_EventLog.ASPx file

< !-- Register the WROXControlLib Assembly -- >

<%@ Register TagPrefix="CPU" NameSpace="WROXCPUCONSOLE.ControlLib" Assembly="WROXControlLib" %>

runat="server"

Machine="machine">

Code Behind vw_EventLog.ASPx.cs file

public class vw_EventLog : System.Web.UI.Page

{

//Event Log Custom Control

protected WROXCPUCONSOLE.ControlLib.eventlog eventlog1;

private void Page_Load(object sender, System.EventArgs e)

{

//Set the machine property from the Query String

eventlog1.Machine = Request.QueryString["machine"].ToString();

}

}

Event Log Application Available in the Code Download

vw_Process.ASPx

Call the process panel control by the tag prefix colon and the class name of process.cs. Note that we set a property from the query string in the code behind file.

Display vw_Process.ASPx file

< !-- Register the WROXControlLib Assembly -- >

<%@ Register TagPrefix="CPU" NameSpace="WROXCPUCONSOLE.ControlLib" Assembly="WROXControlLib" %>

runat="server"

Machine="machine">

Code Behind vw_Process.ASPx.cs file :

public class vw_Process : System.Web.UI.Page

{

//Process Custom Control

protected WROXCPUCONSOLE.ControlLib.process processes;

private void Page_Load(object sender, System.EventArgs e)

{

//Set the machine property from the Query String

processes.Machine = Request.QueryString["machine"].ToString();

}

}

Process Panel Application Available in the Code Download

vw_Service.ASPx

Call the service panel control by the tag prefix colon and the class name of services.cs. Note that we set a property from the query string in the code behind file.

Display .ASPx file

< !-- Register the WROXControlLib Assembly -- >

<%@ Register TagPrefix="CPU" NameSpace="WROXCPUCONSOLE.ControlLib" Assembly="WROXControlLib" %>

runat="server"

Machine="machine">

Code Behind .ASPx.cs file:

public class vw_Service : System.Web.UI.Page

{

//Service Custom Control

protected WROXCPUCONSOLE.ControlLib.services service;

private void Page_Load(object sender, System.EventArgs e)

{

//Set the machine property from the Query String

service.Machine = Request.QueryString["machine"].ToString();

}

}

Service Panel Application Available in the Code Download

Web.config

We tie the CPU Console together using the web.config file; here security is set for the entire application and any assemblies this application will execute. We impersonate the client's identity to call the assemblies, which in turn uses the client's identity to call the event log, processes, and services on any machine the user has access rights to. By setting the authentication type to Windows, ASP.NET will automatically retrieve the username and password when the user logs in. Web.config file should contain the following elements.

IIS Configuration

The final step is to configure IIS. In order to configure IIS correctly, and separate the release version and development versions, build the release version of our ASP.NET Web Application in the Program Files folder instead of the Inetpub folder.

Open Internet Services Manager, right-click on the default web site. Choose New | Virtual Directory. Click Next, and enter an alias, such as CPUConsoleApp (do not choose the same name of the ASP.NET Web Application). Browse to the ASP.NET Web Application that was moved out of inetpub\wwwroot. Click finish to complete the setup.

The new Virtual Directory will now be viewable; right-click and select properties. Click Directory Security | Edit. Uncheck all the boxes except for Basic Authentication, and click the Edit button besides Basic Authentication. Type a backslash ("\ ") in the Domain text area. The backslash allows users of the console to control multiple domains. Click OK on each of the three forms open to complete the configuration. Stop and start IIS to ensure proper configuration settings before viewing the application. Users must be in the group of administrators on the server and the machine they connect to.

IIS Authentication Configuration

The Web Application will be viewable by opening Internet Explorer and typing the following URL into the address bar.

http://localhost/VirtualDirectory/ASP/vw_Default.ASPx

If IIS is configured correctly, there will be a prompt to log in before entering the web application. Use a Windows 2000 Account Domain\UserName for the User Name input, and the password of the account.

Login Prompt on Entrance of the Web Application

Conclusion

Our completed online CPU Console is a multi-tiered, robust, reusable application that is easily modifiable, and serves an important business purpose. In the downloadable code, connect to the vw_default.ASPx web form in the ASP folder to allow the user to select a machine name.

By using the Online CPU Console, one can easily administer services, events and processes of any machine, even those machines that are not .NET framework enabled.

责任编辑:admin
相关文章