I
idiot
When I call PolicyHierarchy method in the IE embedded usercontrol, the html
page prompt script error message "security error". It seems that there is no
"SecurityException"?
Html page code :
<OBJECT id='Object1' height=100% width=100%
classid='http:Web.MainFrame.dll#Web.MainFrame.UserControlLogin'
VIEWASTEXT VIEWASTEXT>Failed
</OBJECT>
<script language=javascript>
if(Object1.CheckPolicy())
{
....
}
else
{
....
}
</script>
IE embedded winform unsercontrol
Code :
public void CheckPolicy()
{
try
{
IEnumerator levels = System.Security.SecurityManager.PolicyHierarchy();
while (levels.MoveNext())
{
PolicyLevel level = (PolicyLevel)levels.Current;
CodeGroup group = level.RootCodeGroup;
if (level.Label.ToString( ) == "Machine")
{
if (group.MembershipCondition.ToString( ) == "All code")
{
for(int i=0;i<group.Children.Count;i++)
{
CodeGroup subgroup = group.Children as CodeGroup;
if(subgroup.Name=="[PRODUCT NAME]")
return true;
}
}
}
}
return false;
}
catch(Exception e)
{
return false;
}
}
page prompt script error message "security error". It seems that there is no
"SecurityException"?
Html page code :
<OBJECT id='Object1' height=100% width=100%
classid='http:Web.MainFrame.dll#Web.MainFrame.UserControlLogin'
VIEWASTEXT VIEWASTEXT>Failed
</OBJECT>
<script language=javascript>
if(Object1.CheckPolicy())
{
....
}
else
{
....
}
</script>
IE embedded winform unsercontrol
Code :
public void CheckPolicy()
{
try
{
IEnumerator levels = System.Security.SecurityManager.PolicyHierarchy();
while (levels.MoveNext())
{
PolicyLevel level = (PolicyLevel)levels.Current;
CodeGroup group = level.RootCodeGroup;
if (level.Label.ToString( ) == "Machine")
{
if (group.MembershipCondition.ToString( ) == "All code")
{
for(int i=0;i<group.Children.Count;i++)
{
CodeGroup subgroup = group.Children as CodeGroup;
if(subgroup.Name=="[PRODUCT NAME]")
return true;
}
}
}
}
return false;
}
catch(Exception e)
{
return false;
}
}