C# - Need To Check In Conditional Logic If A User Has More That One Role Associated?
Sep 8, 2010
I need to check in conditional logic if a user has more that one role associated.Script should work like:
If a user has 1 role CODE OKIf a user has more that 1 role CODE ERRORThe method is
GetRolesForUser();
But I do not know how to use it, could you please give me a sample of code? how to implement it, arrays?
View 2 Replies
Similar Messages:
Aug 12, 2010
I'm binding my DataRepeater control to a table that has many columns. I'd like to only display a subset of those, depending on what is populated.How/where should I do my contitional tests within a dataRepeater? This is the code within my itemtemplate:
View 1 Replies
Nov 3, 2010
I have bunch pages and I need to validate data there. If culture for example "es-ES" I should use one validation logic, if culture "en-US" than another validation logic. For example I need validate phone number. Minimum length is 11 digits. For other culture 9 digits.
View 3 Replies
Mar 21, 2011
on my repeater i builed a table and want to show a colum just for user that is in role admin.i need to remove the column in the HeaderTemplate and in ItemTemplate.i could use data logic and add a db column that will be boolean, but then i need to send to the SP the user role.
<asp:Repeater ID="TemplatesList" runat="server">
<HeaderTemplate>
<table>
<tr>
<th>
[code]...
View 1 Replies
May 22, 2010
I roll my own SiteMapProvider inheriting System.Web.XmlSiteMapProvider.I want to override logic of checking user to be in a role specified in siteMapNode's property roles:
<siteMapNode url="Add.aspx?type=user" title="Add user" roles="admin" />
How can I do that? Which class's member does XmlSiteMapProvider call to check that if securityTrimmingEnabled="true"?
View 2 Replies
May 10, 2010
I have a code behind page with two functions that return two counts (iCount and iCount2). In my repeater table I can display the results of the functions just fine, but now I need to do some conditional logic based on the results of the functions, eg:If iCount =>3 AND iCount2 =>1 Then
View 6 Replies
Aug 21, 2010
Is it possible to somehow output some content based upon some conditional check in Razor? If not, I hope this possibility will be added in the future. What I want to do is the following:
[Code]....
View 6 Replies
Apr 28, 2010
There is Role Management feature in ASP.NET It works on local development machine. For our project we need customers admin to be able to create new users and manage their roles. So, basically same what aspnet_regsql.exe does. Question is Should we develop our own pages and forms or use some ready made tool?
View 3 Replies
Jan 31, 2011
How do I check in C# what the current users role is, and print it to the screen.
View 3 Replies
Jun 18, 2010
I was wondering if setting a default value for a SelectList is considered to be presentation logic or business logic? For example, if a requirement is that an Employee cannot be saved without a Location, but 99% of the time the location that would be selected is a particular item -- say Atlanta. Because of this, the location SelectList should be defaulted to Atlanta when ever a entry screen for a new employee is displayed. Should I be defaulting the location in the model or in the view-model? One thing I realized is that the unit tests become awkward because in both cases, I'd be forced to test against a location that will always be present in production but I cannot create a unit test with my own test dataunless "Atlanta" was in the set of locations being used in the test.
View 4 Replies
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
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
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
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
Feb 25, 2010
This might be confusing but ill try to explain the best as i can. I have a gridview that get the data from datatable. This is simulation my grid view.
key data
1 data1
2 data2
2. data2
2. data2
3. data3
3. data3
what i want is make some conditional statement, when value "key" is changed i want to add empty row. so its suppose to be looks like this as result.
key data
1 data1
EMPTY ROW
2 data2
2. data2
2. data2
EMPTY ROW
3. data3
3. data3
View 2 Replies
Nov 22, 2010
There are 10 check boxes in one page. How to code to allow user only check one?
View 1 Replies
Nov 22, 2010
There are 10 check boxes in one page. How to code to allow user only check one?
View 2 Replies
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
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
Jul 18, 2012
trying to get a login script working, its working fine, but now i have a new problem, i have a field im my DB thats called "urole" in that i have 3 roles, Admin, Co-Admin, User.
How can i use something like this on a page.
Code:
If Roles.IsUserInRole("Admin") Then
Label1.Text = User.Identity.Name + " is an Admin"
Else
Label1.Text = User.Identity.Name + " is NOT in an Admin"
End If
I have this script on my login page
Code:
Imports System.IO
Imports System.Data
Imports System.Data.OleDb
Imports System.Web.Configuration
Partial Class DbLogin
Inherits System.Web.UI.Page
[code]....
and then i have this on my default page, thats shows the info from an user, now i just want to show the role (urole) and then use an "If Roles.IsUserInRole" event so i can show some diffrent thing if admin, co-admin or User
Code:
Imports System.IO
Imports System.Web.Security
Partial Class _Default
Inherits System.Web.UI.Page
[code]....
(The aboved is working fine, but its not showing the urole/Role of an user)
View 12 Replies
Feb 18, 2010
In code, how can I change the user's role from one to another?
Let's say the user1 is in Role1. I would like to change his role to Role2.
View 6 Replies
Dec 10, 2010
I have a page setup to manage and create users.. in order to help the process of creation, i woudl like to add the new users to our default "users" role when they click the create button. Below is what is in place for the creation page and the button event tied to the button. I used this from a tutorial i found else where, but dont have the link at the moment if anyone needed it.. but the code below works great when creating a new user
[Code]....
View 5 Replies
Mar 2, 2010
I wish to know the way to add ASP.NET ("Machine_Name"IIS_IUSRS) to user role in COM+ component programmatically using C#. So whenever my COM+ component is being installed, ASP.NET user is created under Role.
View 1 Replies
Jan 21, 2010
is there a way i can get the role in a string variable using the below commands....
System.Security.Principal.WindowsIdentity wi = System.Security.Principal.WindowsIdentity.GetCurrent();
System.Security.Principal.WindowsPrincipal wp = new System.Security.Principal.WindowsPrincipal(wi);
i need this for
FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1, // version
UserName.Text, // user name
DateTime.Now, // creation
DateTime.Now.AddMinutes(60),// Expiration
false, // Persistent
role); // User data
as string role= wp.IsInRole();
but this is not right
View 5 Replies
Feb 12, 2011
The roles of users are not saved. Here is what i am doing:
[Code]....
And i added this to the create user wizard:
<asp:WizardStep ID="SpecifyRolesStep" runat="server" StepType="Step"
Title="Specify Roles" AllowReturn="False">
<asp:CheckBoxList ID="RoleList" runat="server">
</asp:CheckBoxList>
</asp:WizardStep>
View 1 Replies