Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Form Level Role Based Authentication
Message
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Environment versions
Environment:
C# 1.1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01014722
Message ID:
01015417
Views:
17
I did come up with a hack to use the MM Control Security Manager screen to also manage web page security. I don't love it, but it works.

I copied parts of your Render() and GetSecurityIconHtml() methods from your controls and put them in my base web page that I gave the code for in my previous example. When logged into security management mode, this will show the security icon for the page itself in the upper left-hand corner of the page. This works in IE because IE will allow just about any type of HTML, but I can't say the same for other browsers because it renders my img src="" tag after the closing tag because my code is called after the page Render() method.

Here's the trick to get this to work:
1. Set the RequiresSecurity property on your web page = false
2. Assign a ControlID GUID on your web page with the builder
3. Run your web page and the security icon will show up. Click on the icon and use the Security Manager page to give yourself permissions to this page
4. Go back and set the RequiresSecurity property on your web page = true
protected override void Render(HtmlTextWriter writer)
{			
	base.Render (writer);

	if (this.ControlID != Guid.Empty && this.Page is mmBusinessWebPage)
	{
		// *** If we are in security admin mode write out the security icon
		if ( ((mmBusinessWebPage) this.Page).SecurityAdmin ) 
		{
			// This style can be used to position the icon anywhere on the web page
			string Style = "style='position:absolute; left: 30px; top: 10px;";
			writer.Write(this.GetSecurityIconHtml(Style));
		}
	}
}

protected string GetSecurityIconHtml(string Style) 
{
	string AppPath = HttpContext.Current.Request.ApplicationPath;
	string image = AppPath + "/images/security.gif";
	string script = string.Format(@" onclick=""window.open('{0}','security','height=580,width=525,top=0,left=0,toolbar=no,resizable=yes,menubar=no,status=no')"" ",
		AppPath + "/admin/controlsecurityconfiguration.aspx?ControlId=" + this.ControlID.ToString());

	// *** If we have a style and it it includes absolute (position:absolute assume it's positional
	if (Style != null && Style.ToLower().IndexOf("absolute") > -1) 
	{
		int Left = 0;
		int Top = 0;

		Style=Style.ToLower();
		try 
		{
			Left = Int32.Parse( mmUtils.ExtractString(Style,"left:","px") );
			Top = Int32.Parse( mmUtils.ExtractString(Style,"top:","px") );
		}
		catch
		{ 
			// *** Invalid data - we have to exit and not show it
			return "";
		}
			
		string ImgStyle = "style='position:absolute;left:" + (Left - 20).ToString() + "px;top:" + (Top + 2).ToString() + "px;'";
		return " <img src='" + image + "' alt='Manage Security' " + ImgStyle + " " + script + ">";
	}
	
	return " <img src='" + image + "' alt='Manage Security'" + script +">";
}
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform