C# - Find All User That Are NOT In A Specifv Role Using: Roles.GetUsersInRole Or Different?

Jan 27, 2011

I need populate an array with a list of Users that ARE NOT PRESENT in a specific Role and COUNT the result.At the moment I use this code, but I am not able to get the Users outside "CMS-ADMINISTRATOR " role.Any idea how to do it and better write the Count section?

string[] usersInRole;
usersInRole = Roles.GetUsersInRole("CMS-ADMINISTRATOR");
int c = usersInRole.Count();

View 3 Replies


Similar Messages:

User Still Exists In Roles.GetUsersInRole After DeleteUser() With DeleteAllRelatedData = False

Jan 13, 2010

I have an account called "admintest" which is "admin" as its role. I called the following line to delete the user with deleteAllRelatedData=false because I just want to mark the user as deleted (I may need to retrieve users' history later)

bool result = Membership.DeleteUser("admintest", false);

After that, I call the following line to get the user:

string[] users = Roles.GetUsersInRole("admin");

But I still get "admintest" in the users array.

View 1 Replies

Security :: How To Set A Role Of User Having Multiple Roles

Mar 5, 2010

This is my senario. I want user to login and if "LoggedIn" User has more than one role then it displays the list of radio buttons. After selection of the role user gets further privilages according to the role that he has selected.

I've a problem setting up the role. And user can change his role when ever he wants.

For Example "john" is the user having two roles "Account Manager" and "Project Manager".

View 3 Replies

Security :: Roles In FormsAuthentication / Specify The Role Of The Logged In User?

Mar 25, 2010

In my website i am creating a custom FormsAuthentication ticket during log in. This ticket stores the userid but i also need to specify the role of the logged in user. How do i do it?

View 2 Replies

MVC :: Custom Membership / Role Provider Works But Seems Unable To Determine User Roles

Apr 26, 2010

I created a custom forms authentication and membership provider and it seems to work fine opening up in WAT, creating roles and adding users. Also when I in my mvc app use it to log users in, it works fine. However it seems to fail to determine a user's role (no errors, but just jump over User.IsInRole(...) lines and Roles.GetRolesForUser(); comes up empty. I got a gut feeling I did something wrong with my configuration, so for now I'll post just that:

[Code]....

View 6 Replies

Security :: Find The Current User's ROLE?

Feb 4, 2010

For some reason I couldn't find it anywhere, how do I find the current user's role in vb.net?

View 3 Replies

Security :: How To Find Out If The Current User Is Elligible To View An URL Based On Role Provider

Aug 17, 2010

I want to execute some logic if the Logged in User can view a page "~/MyPage.aspx". IF the logged in user should be elligible to view the page is determined by the role based security I configured in the web.config file. There are many methods to find out if the user is in role XXX or not. But I did not find any method to find out if the user can view a page or not ahead of transferring the user to that page. Maybe I will hide a link to a specific page to the logged in user if the user is not elligible to view that page if I know the technique i am asking here to know.

View 1 Replies

Web Forms :: Set Roles Without Membership And Role Providers?

Mar 10, 2010

how do i do that through config file?

View 11 Replies

How To Make All Of The Roles Defined In RoleGroup> Required? (i.e. User Must Meet All Roles)

Feb 24, 2011

Let's say I have a rolegroup as follows:

<asp:LoginView ID="lvDoSomeStuff" runat="server">
<RoleGroups>
<asp:RoleGroup Roles="RoleOne,RoleTwo">
<ContentTemplate>
...
</ContentTemplate>
</asp:RoleGroup>
</RoleGroups>
</asp:LoginView>

Is there a way I can make it so that a user must meet RoleOne and RoleTwo to satisfy the RoleGroup? By default, if a user is in either of the two roles, they will be granted access. I know I can do this via the code-behind, but I'd prefer to be able to wrap some content template with this markup instead of having to wrap it in a panel and hide the panel programmatically.

View 1 Replies

.net - Implement A Custom Role Provider Which Supports Sub Roles?

Jul 28, 2010

how to implement a custom role provider which has support for parent and child roles?

I have a requirement to have high level Role permissions as per the usual Role provider functionality. However, I also have a requirement to further breakdown permissions into sub roles. I toyed with the idea of having further role instances for sub permissions but I'd prefer to have a native solution which allows for sub roles.

For instance:

[IT]
[IT] > [Admin]
[Extranet]
[Extranet] > [Admin]

In this scenario, the "Admin" role is actually 2 distinct roles, one for IT and one for Extranet scenarios. Ideally, there is no association between the 2 "Admin" roles because they are unique sub roles.

[Edit]: Following Igor's comment I feel I should clarify. The aspnetdb is already hosting multiple applications and therefore the use of the Application Name is not possible to segregate the sub roles as it is already being used to seperate the roles by application.

View 2 Replies

User Is In Role "admin" But (Authorize (Roles="admin")) Won't Authenticate

Mar 15, 2011

I found a great answer on SO describing how to set up custom user roles, and I've done the same in my project. So in my Login service I have:

public ActionResult Login() {
// password authentication stuff omitted here
var roles = GetRoles(user.Type); // returns a string e.g. "admin,user"
var authTicket = new FormsAuthenticationTicket(
1,
userName,
DateTime.Now,
DateTime.Now.AddMinutes(20), // expiry
false,
roles,
"/");
var cookie = new HttpCookie(FormsAuthentication.FormsCookieName,
FormsAuthentication.Encrypt(authTicket));
Response.Cookies.Add(cookie);
return new XmlResult(xmlDoc); // don't worry so much about this - returns XML as ActionResult
}
And in Global.asax.cs, I have (copied verbatim from the other answer):
protected void Application_AuthenticateRequest(Object sender, EventArgs e) {
var authCookie = Context.Request.Cookies[FormsAuthentication.FormsCookieName];
if (authCookie != null) {
var authTicket = FormsAuthentication.Decrypt(authCookie.Value);
var roles = authTicket.UserData.Split(new Char[] { ',' });
var userPrincipal = new GenericPrincipal(new GenericIdentity(authTicket.Name), roles);
Context.User = userPrincipal;
}
}
Then, in my ServicesController class, I have:
[Authorize(Roles = "admin")]
//[Authorize]
public ActionResult DoAdminStuff() {
...
}

I login as a user with the "admin" role, and that works. Then I call /services/doadminstuff - and I get access denied, even though when I put a breakpoint in Global.asax.cs, I can see that my roles do include "admin". If I comment out the first Authorize attribute (with roles) and just use a plain vanilla Authorize, then I can access the service.

View 1 Replies

C# - Show List Of Roles In A Dropdown Box But Leave Out "Admin" Role?

May 11, 2010

I have a dropdown box showing a list of roles. I used Roles.GetAllroles() for showing all roles in the dropdown box but I don't want to show a role named "Admin" in the dropdown box. How can I keep it out?

View 2 Replies

C# - GetUsersInRole DataSource For DropDownList

Nov 22, 2010

I need to display in DropDownList a list of "Users" belonging a specific ROLE. This is my code:

// Find DropDownList
DropDownList myUserList = (DropDownList)uxInsertAuthorInput.FindControl("uxUserListSelector");
// Bind data to DropDownList
myUserList.DataSource = Roles.GetUsersInRole("CMS-AUTHOR");
myUserList.DataBind();
myUserList.DataTextField = "UserName";

My problem is when a visitor select an item in DropDownList. The actual value passed is the "UserName" and not the "UserId". I need to use the "UserId" value when a visitor select an item from DropDownList. How to do it?

View 2 Replies

C# - EF - Find All Users In A Specific Role And Populate A DropDownList Using List?

Feb 1, 2011

I use EF 4 and Membership Provider Shipped with ASP.Net 4.0.

I need find all Users in a Specific Role and Populate a DropDownList using List<ListItem>.

DataBase Tables involved are:

[code]....

Problems:

IF return FALSE always, so I am not able to populate List<>.

I suppose I am doing wrong in if an some Properties.

View 1 Replies

User Controls :: Save And Retrieve CheckBoxList Values As Per User Roles?

Feb 26, 2014

i need a script on ASP.net that can build this form.

1.Users === Drop Down Menu then in the Drop down should be the names of all Taafoo staff.

View 1 Replies

Security :: Enable User To Edit / Delete Based On User's Role Permission

Feb 24, 2011

I'm trying to allow logged user who are in department XYZ to perform some task for my third party App. I have two SQL tables named Users & UserList. The third party app (GoldMine) graps the USERNAME from the Users table and store it as UserID which I then referecnce SessionID. The UserList table has two columns (GM_UserName & Department) which I'm interested in. When a user login into the 3rd party app (GoldMine), i then compare the USERNAME (from Users table) to GM_UserName (from UserList table) and see whether GM_UserName is in = 'Dept XYZ'. Take a look at the SQL query below.

sqlDept = "SELECT USERNAME FROM Users LEFT JOIN UserList ON UserList.GM_UserName=Users.UserName WHERE UserList.Department ='Dept XYZ'"

I'm able to do this.

If Session("Userid") = "TestUser1" Or Session("UserID") = "TestUser2" Then Do this Else Do that End If
BUT unable to do this...
If user's Department = 'Department XYZ' Then
Do This
Else
Do that
End IF

View 2 Replies

MVC :: Strongly Typed User Control On All Pages Based On Login Status And User Role

May 9, 2010

I want to display a menu (which will be strongly typed with it's own unique model) across all pages only if a user is logged in.What menu items are available depend on the user's role and also I'll need to hit the repository to get numbers like "x Messages", etc

Been scratching my head for a simple solution here. Don't want to create something that need changes all over the place.All my controllers derive from a BaseController, all my Models from BaseViewModel....probably where I'll be implementing functionality for this.

View 3 Replies

User Controls :: Show Hide Specific Section Of Page Based On User Type Or Role

May 7, 2015

I have LOGIN PANEL for student, and I want to disable it in different page. And only the admin can enable and disable it. I dont know the logic behind here.

View 1 Replies

User Controls :: How To Set User Roles During Registration

May 7, 2015

In Below link show to how to Imaplement role based security, Page access and show / Hide Menu items based on Role in asp.net

[URL]

But My Questions is How to Register Admin and Client user?

View 1 Replies

C# - How To Set User Control Visibility, Upon User Role

Mar 11, 2011

I want to implement access control for usercontrols depending on user role(s), I want to do it on the control base class, in such way that on every user control I only need to set a string with allowed roles to see the user control

This is how an user control class may look like:

public partial class SimpleMenu : MyUsrControlBase
{
protected void Page_Load(object sender, EventArgs e)[code]...

How to set up user control visibility from the base class depending on the validation result?Also which event in the user control is the best to set the roles?

AlloweRoles = "RoleA, RoleB"

View 1 Replies

Web Forms :: Add "role" Parameter / Property To User Control Containing LoginView Control To Set "Role" Possible?

Jan 13, 2010

I am in the process of creating a user control that enables content areas of our web application to be editable. The control utilizes the asp.net membership/role providers and incorporates a LoginView that only displays the edit link if a user has logged in and is a member of the desired role. What I would like to be able to do is pass the "role" as a property of the control so it can be set dynamically and does not have to be hard coded into the control if I use elsewhere in another application.

View 3 Replies

Can User Have More Than One Roles

Apr 3, 2010

I'm developing a web application I want to use the role authentication to control different parts of the website accessibility. But my problem is say I implemented a upload and download functionality on one of the page and I want to have the ability to control a user whether they can either upload or download; or both. So, I'm not exactly sure if the role base authentication can support a user with more than one role to work the way I want it.

View 1 Replies

Losing User Roles?

Aug 11, 2010

I am baffled, I am using a treeview to set the source of an iframe. The web page is being displayed correctly, but User.IsInRole("roleName"), in the code behind, always returns false. The strange thing is User.Identity.Name returns the correct user name. I have tried setting the target of the tree view nodes to "_blank" and to "_self" and still no luck. So, it doesn't appear that the problem is related to the iframe.Before the treeview was added, javascript was used to set the source for the iframe and User.IsInRole returned the correct values.

View 4 Replies

How To Add .net User .net Roles For Application From IIS

Sep 6, 2010

I am not sure is there any other way to add User for my application othe than using Asp.net Website admistration tool??

View 1 Replies

Security :: How To Get The User's Role

Jan 22, 2011

Is there any way that I can find the exact name of the role a User is in? There is a property for UserName ( User.Identity.Name) but what about the role?

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved