Shoud I give up to determine user role programtically????
From: TJ (TJ_at_discussions.microsoft.com)
Date: 09/10/04
- Next message: Mike Walsh: "Re: Modify My Page changes Shared View too"
- Previous message: ferretwoman: "Modify My Page changes Shared View too"
- Next in thread: [SPE] Dustin Miller: "Re: Shoud I give up to determine user role programtically????"
- Reply: [SPE] Dustin Miller: "Re: Shoud I give up to determine user role programtically????"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 9 Sep 2004 20:29:01 -0700
Hi,
I am developing one web part that needs to show the site role of current
user..
Here is my code.
Impersonator i = null;
try
{
i = new Impersonator("administrator", "mydomain", "mypassword);
if(i.Impersonate())
{
SPWeb currentWeb = SPControl.GetContextWeb(this.Context);
SPRoleCollection currentRoles = currentWeb.CurrentUser.Roles;
foreach(SPRole myRole in currentRoles)
{
output.Write("Current Role: " +
SPEncode.HtmlEncode(myRole.Name.ToString()) + " <BR> " );
}
}
catch(Exception exp)
{
output.WriteLine("Failed: " + exp.Message);
}
finally
{
if (i != null)
{
i.Undo();
}
}
I tried everything such as giving the full-trust and impersonation.....but
no lucks at all....
When administrator logs in, the role was displayed correctly on the web
part...
However, if non-administrator logs in, login dialog box keeps poping up, and
then finally error message says that
Access denied. You do not have permission to perform this action or access
this resource.
Access requests are not enabled.
I really do not have any idea why it didn't work at all....
As I said, giving full-trust and impersonation that I tried every possible
things to work for this code, however, I coud't make this code working...
What am I missing for this issue???
Thank you in advance.
...................................................................TJ
- Next message: Mike Walsh: "Re: Modify My Page changes Shared View too"
- Previous message: ferretwoman: "Modify My Page changes Shared View too"
- Next in thread: [SPE] Dustin Miller: "Re: Shoud I give up to determine user role programtically????"
- Reply: [SPE] Dustin Miller: "Re: Shoud I give up to determine user role programtically????"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|