Hello BJ,
From your description, you're meeting some problem to get the
"PrincipalPermi ssion" demand to work in your vs 2005/.net 2.0 program,
correct?
I've performed some local tests through winform application, it seems that
the "PrincipalPermi ssionAttribute" can work correctly for custom
principal/identity or windows principal/identity associated with the
current thread. Also, according to the MSDN document, it indicate that we
should set AppDomain's PrincipalPolicy to "WindowsPrincip al" at
application's initializing time
#PrincipalPermi ssionAttribute Class
http://msdn2.microsoft.com/en-us/lib...ssions.princip
alpermissionatt ribute.aspx
My test code is as below, you can also have a test to see whether it works
for you:
=============== ========
private void btnSetPrincipal _Click(object sender, EventArgs e)
{
GenericIdentity identity = new
GenericIdentity ("testuser", "customauth ");
GenericPrincipa l gp = new GenericPrincipa l(identity, new
string[] { "role1", "role2" });
Thread.CurrentP rincipal = gp;
}
[PrincipalPermis sion( SecurityAction. Demand, Role="role1")]
private void btnDemand_Click (object sender, EventArgs e)
{
MessageBox.Show ("success demand!");
}
private void Form1_Load(obje ct sender, EventArgs e)
{
AppDomain.Curre ntDomain.SetPri ncipalPolicy(Pr incipalPolicy.W indowsPrincipal )
;
}
=============== ==========
In addition, you can try programmaticall y construct a PrincipalPermis sion
class instance and call its "Demand" method to see whether it works. Also,
make sure your principal-demand method hasn't been called on a different
thread context(you can printout the thread's principal/identity context to
verify this).
If you have any further finding, please feel free to post here.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.