.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Check User Roles (more than 50)

Posted By:      Posted Date: September 30, 2010    Points: 0   Category :ASP.Net

I have more than 100 roles defined for my app. Now I have a page which is allowed for around 50 roles,
so when user comes to page instead of writing too many if else conditions, what is the best & efficient way
to check the if user in any of those 50 roles?


I have more than 100 roles defi

View Complete Post

More Related Resource Links

Adding user to certain roles


I have setup ASP security in my application. I used the following tutorial, just wondering if someone can tell me how i can setup this up to allow the creation of a user?


Can someone tell me where to find or what to search on to find some example of how to add the option for adding users?

I have the above setup and its working, but only because of the accounts i created with my global.asax file.
I need to give the admins access to add a new user. Currently i can search on existing users and update them, but need to add the ability to add a new user.

How To Check if user is already logged to another computer..???

By the way.,, I am new here.... I  am doing a little vb.net windows form project but connected with the internet ... question : how can I check if the user is already login to another computer..??   somebody here please.. ideas.. thanks..... : )    

How to check effective permissions for a user or group for a SQL server object or whole server?

Guys, How do I see effective permissions for a user or group for a SQL server object or whole server? For example, a user is not listed in security/logins, but he is a member of few groups and some of them have assigned permissions on SQL server (again either directly or through membership in other groups) Even when I select an object (a table), check properties/permission – it doesn’t let me select any principal, except those listed on security/logins… Anyway, what is the right way to see effective permissions for a user or group? Sorry for asking such a simple question, I’ve searched but found nothing relevant.

Checking SQL Server User Roles and Creating SQL Server Users using VB.NET

Hello gurus!Firstly I want to apologies if this question is out of place here.. if someone can direct me to the correct forumn great and Thanks!I have a VB.NET application which uses its own Backend Database (MSSQL Server). I need to distribute this application to sites where there will be an existing SQL Server.So I will need to Create the Database on this server. The Application includes methods for building the database on startup if not already connected to one.However the users windows logon may not have the correct permission to connect and create a Database on the Server. I have a DB Setup form in my application which asks for the Servname, Username, Password and Database name. I have catered for Windows Authentication and SQL Server Authentication within the form - the user makes the choice.Assuming they enter a Username and Password for SQL Server Athentication then I will be trying to connect using this user and create the database on the given server. The following is my outline logic:-                                                                  Create db Process                                                                             |                                                                             |                                                               Check Credentials                                                                   / 

How to check if a given user is local admin or not

Hi, How to check if a user (may be domain user also) is part of local administrators group or not? Note I am NOT talking about checking of current logged in user. I should send the username & passowrd of any user (may or may not be domain user) & that should flag me whether that user is local admin or not. Please help.

check user exists in which group

After entering user name, i want check user belonging to which group, group is some thing like role based if group is something group1 , then i want redirect hime to page 1, if groupis 2  then page 2 like that

Check membership roles

Hello All, I have the following, for an webapplication I user membership roles. Users are added or removed from a role. I have two things i am wondering how to accomplish.   The first: New or exisiting users have assigned roles for their accounts. This roles can be selected or deselected from a checkbox (when the users is created or edited) . I want to build some routine or function to see if a users is part of a role or if he is assigned a new role. When, in edit mode, a users is part of a role the particular checkbox has to be checked, or if he isn't unchecked. Of course I want to call a function to do that so I don;t have to write the if then statement for all roles, but just one time. I think this should be a public function to call from all pages within the appication, but whatever i try, it doesnt work.  I have written a function in a apart classfile called functions.vb. But the roles syntax isn't recognized. Herby the function{Public Function CheckMembership(ByVal GroupName As Boolean, ByVal User As String, ByVal Group As String) As Integer If GroupName = True Then If Not Roles.IsUserInRole(User, Group) Then Roles.AddUserToRole(User, Group) ElseIf GroupName = False Then If Roles.IsUserInRole(User, Group) Then Roles.RemoveUserFromRole(User, Group)

Redirect to specific page based on user Roles

I am using Formsauthentication. My situation is as per below:the login form has codebehind :==============================protected void LoginButton_Click(object sender, EventArgs e)        {            TextBox uname = Login1.FindControl("UserName") as TextBox;            TextBox pass = Login1.FindControl("Password") as TextBox;            CheckBox rm = Login1.FindControl("RememberMe") as CheckBox;            Literal fail = Login1.FindControl("Literal1") as Literal;            if (Membership.ValidateUser(uname.Text, pass.Text))            {                /                FormsAuthentication.SetAuthCookie(uname.Text, rm.Checked);                            }        &

Document is read-only in SharePoint, but user sees "check out" option in Office 2007 / Word / Excel

I am finding that when there is a document library in SharePoint with checkin/checkout required, if a user with read-only ("Visitor") permissions opens a document from that library, the document will open as read-only in Word, Excel, etc., but the user will see the "Server Document" bar with the message "To modify this document, you must check it out" and the "check out" button.  When the user tries to check the document out, they are asked to authenticate, and then receive the error "Cannot perform this operation.  The file has been deleted or someone else has it checked out."    How is it possible to prevent a user with read-only rights in SharePoint from seeing the "Check out" option in Word or Excel?

Check user and pass at login

Hello!I use a class method that looks something like this to check for user and pass at login:public static bool checkUser(string conn, string user, string pass) { SqlConnection conn = new SqlConnection(conn); string sql = "SELECT User, Pass FROM TableUser WHERE User = @user AND Pass = @pass"; SqlDataAdapter da = new SqlDataAdapter(sql, conn); SqlParameter daUser = da.SelectCommand.Parameters.Add("@user", SqlDbType.NVarChar); SqlParameter daPass = da.SelectCommand.Parameters.Add("@pass", SqlDbType.NVarChar); daUser.Value = user; daPass.Value = pass; conn.Open(); DataSet ds1 = new DataSet(); da.Fill(ds1, "tbl"); int i = ds1.Tables["tbl"].Rows.Count; conn.Close(); if (i == 1) return true; else return false; }...and I just wanted to ask, if there is a shorter/faster way (the user table is on an SQL Server? Also is this way secure?Note: I set the collation for the password field on the SQL Server to be case sensitive so I don't have to account for it in the code.Thx!M

Alerts - 1 user fails with "PermissionMask check failed. asking for 0x00000055, have 0x3C4312EF", ot

I have set Alerts for 3 users on a Document Library in our Team Site in a MOSS 2007 environment.  Alerts go out for every other person I set alerts for, with the exception of this person.  Our Exchange Admin tracked down the Alert email and saw that while everyone else was listed, this person was not.  At the same time I turned on Verbose logging for the log files and found the PermissionMask failure.  The problem is I cannot figure out why this person is failing this check. This person happens to be a member of our IT team, as are the other people I added Alerts for.  I should also note that this problem occurs whether I add the alert for this person, or this person adds the alert themselves.  I have checked the permissions on the Library and they are inherited from the Site level.  When I check the permissions on the Site level, the IT team has Contribute permissions, I did then check the AD Security Group to be sure that this person is in the group, and they are. Any ideas as to why this would happen for this person only?  This person can access, and add content, to the Library which puzzles me more.  My next test will be to add this permission to the Site permissions explicity with Full Control to see if that matters. In Googling for this, I find a number of PermissionMask posts, but none that seem to address this specific pro

Check session timeout and warn user before timeout


I know there are several articles explaining how to warn the user before their session times out, but so far none of them have worked for our scenario, so I'm hoping someone here will be able to help me figure this one out...  Here's what we've got:

Our application uses SQLServer to store session state.  We've got it set to timeout in 60 minutes.  Unfortunately (I fought hard against this, but lost the battle) our application uses popups for several major screens.  So tracking the session timeout on the client side doesn't really work, because I have no idea what window the user is in at any given point.  I've tried the solution where you inject Javascript into the page using the current session timeout on each request, but again, because the user could be actively using the application in a different window, it doesn't work for us.  So I guess I have a couple key questions:

  1. Is there any way to get the timeout for a session without triggering a request to the server, which would just renew the session?
  2. Is there a way to track the session timeout value across multiple windows? 
    I believe there is a limit to the number of "branches" the main window can have in our app.  In other words, the user can only be 2 levels deep from the main/root window, s

How to check whether user is manager or normal user


How to check whether user is manager or normal user

Use of aspnetdb configuration for user login,roles and all



I created a web application and i created the users,roles and all using the asp.net configuration,

the aspnetdb is created and i include that in my project adn run it it works fine.

then i copy the whole folder in my root folder of my IIS and it works perfectly fine

Now if i want to create the whole project into an exe such that  if i run the exe on a system that has iis on it,it should automatically create the virtual directory and i shud be able to run it from the new server.

i tried it but the login is not working,

Can you help me finding out the exact way in which i can create the login features using the asp.net configuration.

How to check user is a particular group


How to check user is related to a particular group , if he is assigned to multiple groups

SQL Query for Date Check User Dates



I am using two columns in one table such as StartDate,Enddate.

In asp.net Form two text boxes there. One is StartDate other one EndDate..

When user Click Submit button the Two dates is compare above DataFiled's...


-------- Data Base Values ----------------

StartDate            EndDate


10/09/2010         14/09/2010

16/09/2010         28/09/2010



user send Start Date ' 27/09/2010' and EndDate '30/09/2010'


Now the Query Check Dates Between Userdates avialable in Database....


What I ll do?????


(Note : Opertion only allow the Dates Not Exists in Database Dates)



How can you check the user is owned of the web site that is input in textbox?


Hi Experts.

In the most web sites when you want to register in any web sites, you must provide your information such as First name, last name, email and etc. Then the web site create a confirm link and send it to your mail. If you input your mail correctly, you can check it in your inbox of your mail and click on it to your registration is completed.

In this scenario, the users should input their mails correctly because the web sites will send the confirm link to it. In other words the mail that the users input must be owned of user else if they can't click on the confirm link.

Suppose you want the users input their web sites instead of their emails address in your web site, Now How can you check the user is owned of the web site that is input in the textbox?

I hope you understand my question else if tell me to describe it more.

With Regards. Mojtaba

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend