Hi,
I'm testing the IsInRole method on my app. I'm using Integrated security so
I'm not sure if that has something to do with it. I have a groups table
which I want to secure certain portions of my application.
In the global.asax:
protected void Application_Acq uireRequestStat e(Object sender, EventArgs e)
{
if (Request.IsAuth enticated)
{
string[] arrRoles = new string[]{"Manager", "Cleaner"};
System.Threadin g.Thread.Curren tPrincipal = new
System.Security .Principal.Gene ricPrincipal(Co ntext.User.Iden tity, arrRoles);
}
}
In a page secured by integrated security I get "false" for the following code:
Context.User.Is InRole("Manager ") //-returns false when I thought it should
be true?
Thanks 2 3240
I'd really create my own object to keep track of these roles. Attaching to the context works great for a forms-authentication app, but when you throw windows authentication into the mix, by default, IsInRole will be checking active directory groups. You are essentially trying to overwrite this, which to me doesn't seem like a good idea. You'll have a lot more flexibility down the road if you create your own object to check these roles, and just store that in the session.
--Michael
"Dave" <Da**@discussio ns.microsoft.co m> wrote in message news:F1******** *************** ***********@mic rosoft.com... Hi, I'm testing the IsInRole method on my app. I'm using Integrated security so I'm not sure if that has something to do with it. I have a groups table which I want to secure certain portions of my application. In the global.asax: protected void Application_Acq uireRequestStat e(Object sender, EventArgs e) { if (Request.IsAuth enticated) { string[] arrRoles = new string[]{"Manager", "Cleaner"}; System.Threadin g.Thread.Curren tPrincipal = new System.Security .Principal.Gene ricPrincipal(Co ntext.User.Iden tity, arrRoles); } } In a page secured by integrated security I get "false" for the following code: Context.User.Is InRole("Manager ") //-returns false when I thought it should be true? Thanks
Hi Dave,
Role name like user name should also include domain name:
User.IsInRole(" Your_Domain_Nam e\Manager")
HTH
Elton Wang el********@hotm ail.com -----Original Message----- Hi,
I'm testing the IsInRole method on my app. I'm using
Integrated security soI'm not sure if that has something to do with it. I have
a groups tablewhich I want to secure certain portions of my application.
In the global.asax:
protected void Application_Acq uireRequestStat e(Object
sender, EventArgs e){ if (Request.IsAuth enticated) { string[] arrRoles = new string[]
{"Manager", "Cleaner"}; System.Threadin g.Thread.Curren tPrincipal =
newSystem.Securit y.Principal.Gen ericPrincipal
(Context.User.I dentity, arrRoles); } }
In a page secured by integrated security I get "false"
for the following code: Context.User.I sInRole("Manage r") //-returns false when I
thought it shouldbe true?
Thanks
. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Kevin |
last post by:
Hello all,
I'm unable to get the IsInRole method to work with my AD domain. There is a
global group that I am a member of, when I query that group using the
IsInRole method, it returns false.
One question that I had, is there anything different that has to be done
with AD when using this method? For example, I'm populating a list box with
the members of this group, and when I attach using LDAP I had to use...
|
by: Alek Davis |
last post by:
Hello,
I noticed an interesting problem. When calling WindowsPrincipal.IsInRole
over dial-up (VPN), this function takes 1-2 minute(s) to return. On the
intranet or when disconnected from the network, it is instantaneous. Even
more interesting is that IsInRole checks for a local group (e.g.
Administrators), not a domain group, so I am not sure why it would make such
a difference. Either version of IsInRole (with a string parameter and an...
|
by: JIM.H. |
last post by:
Hello,
username=user.identity.name
trueFalse=User.IsInRole("myDomain\Administrators")?
First line return user name as administrator but second line returns false? What might be the reason? Or how does isInRole work?
Thanks,
Jim.
|
by: arjun |
last post by:
Hi All,
I am developing a A webpage to be seen in a page viewer
webpart(Sharepoint 2003).
The page is supposed to check for the current user name and then check
the user membership in some local group membership.But here I am
failing .The isinRole call on the Principal object is returning true
for buitin groups and some local groups but not ALL.
I read in one of the previous threads that this was a bug in Framework
1 in which all groups...
|
by: Peter |
last post by:
Hello!
I have a strange problem with .IsInRole method. When I use this method on my
development machine everything works fine. However when I deploy my
application on a production server this method does not work correct.
I use the following code:
String DefaultAdminRole = @"dom\admgroup";
String UserName="";
| |
by: Oliver Rainer |
last post by:
Hi, I have the following problem...
Pre-requisites:
Installation of an Asp.net webservice on a IIS5 server (win2k). Anonymous
access is not allowed, only using windows authentication (intranet app),
webmethoda are using the Principalpermssion attribute
() for identification.
Result --> does not work
|
by: Bob |
last post by:
I created a usergroup on my W2K AD domain server and called it MyCustomRole
I added my user to it named User Name fully qualified is Mydomain\Bob
I can see that My.user.name Is OK its Mydomain\Bob But when I run the line
If My.User.IsInRole("MyCustomRole") Then
it returns false.
|
by: Bob |
last post by:
This a bit of a second post on same subject, my apologies.
IsinRole function only works with built-in roles. If I create a new group on
my domain controller then add an existing user to that group, user bob,
group TestUsers and then try to determine if My.user.Isinrole("TestUsers") I
always get a false, which is incorrect.
If I put Bob as part of Administrators or any other built-in group on the DC
and look at...
|
by: Andy |
last post by:
Hi,
I currently have my application setup and built using Windows
Authentication (WindowsPrincipal). For security checks, I simply do
an IsInRole call on the Principal. The role permissions are hard-
coded, something like this:
private static string allowedReadRoles = new string { "Sales",
"Ordering" };
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |