Check To See If A Given Username Is In A Certain Role?
Jul 6, 2011
I have an ASP.NET application on our company's intranet. And a funky security requirement.
I need to check to see if a given username is in a certain role. I cannot use
Page.User.IsInRole("MyDomainMyGroup")
because
Page.User.Identity.Name
Returns an empty string. Because of some lovely specifications for this program, I have to keep anonymous access enabled in IIS. Seems to rule out any page.user.identity stuff.
So I did find a way to (at least) get the current user (from System.Environment.UserName), but I need to bounce it against the domain group to see if they're in it. Or, better yet, get a list of users within a given domain so I can check myself. Something like...
Dim UserName as String
UserName = System.Environment.UserName
If User(UserName).IsInRole("MyDomainMyGroup") Then
In my VS solution, I have two projects.One for the Web Interface, other for DataAcess and BusinessLogic. I know I can check if the currently logged-on user is Employee in Web Interface project like this from the code behind:
Dim isEmployee = User.IsInRole("Employee")
The problem is that I have a Class call UserManagement in my the DA and BL project which I want to check the currently logged-on user role also. I can't use Dim isEmployee = User.IsInRole("Employee") because it doesn't have aspx page.
What do I need to do to check the user role in my custom class?
I have an asp.net web forms application that uses asp.net membership and URL Routing.Because of the way Roles work, i cant put an "AND" or "OR", etc. in the allow/deny tags of the web.config file that resides in each folder.This is a business website that that is being ported from a vb.net win forms project that contianed many apps. (The win forms project have a custom authentication system.)The web app is structured in a way to mimic the desktop suites and a folder was created for each app.There are also common folders where any user of any app can generate a report.
I'm doing an application to manage a school of music, at the moment i'm working on registration (with MySQL DB).
Imports MySql.Data.MySqlClient Public Class Admin_Reg Dim server As String = "Server=localhost;Database=escola_musica;Uid=root;Pwd=;"
[Code].....
Now i want to verefy the table if the username exists or not. If it exists msgbox "Registration Complete", if not "Username already exists. Choose another one..."
im using VS08 and i got this script to check if username is in database if not insert it which works halfway lol which it says the username is being used even when there is no username in database.. here is the script
Call ConnectDatabase() Dim myAdapter As New MySqlDataAdapter Dim query As String
[code]....
and is there a way i can create a label on login form and when the user creates a username it will go to the login form and put up on the label "you have created a username" or something like that?
I have this code that it's suppose to check if the username exists and if it is doesn't insert but it does: Imports MySql.Data.MySqlClient Public Class Admin_Reg Dim server As String = "Server=localhost;Database=escola_musica;Uid=root;Pwd=;" Dim con As New MySqlConnection Private Sub Admin_Reg_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load [Code] .....
Where is a good VB.NET tutorial where I can have a username box and a password box and it checks in the database if it's there and if it is then another form will show?
I am working on a code for a chat client/server and I have it all working, I can connect and chat locally and global. The problem I am having is that when someone just hits the X in the corner to exit it crashes my server as well as the fact that if someone wants to they can make their username the same as someone elses.
I've created a new datasource dtsLogin containing an ID, username and password. my problem is how can you check if the username & password typed in the textbox are the same as the one on the Access database? I thought maybe using a rowfilter but I'm not that good in ADO.net.
So far i have a normal login system but want to add 3 radio buttons.you have to enter the right username and password then check the right radio button..
I have a chat server / client system running, but I want users to authenticate with my vBulletin forum database.I don't want the client to do it, because it is possible to fake the 'successful login' and connect with a fake username. I want to send the username and password details to the server, and make the server check it with the local vBulletin MySQL database for the username and password.Is there a way to do this? To my knowledge vBulletin has a username and a password entries in the database which is salted, and the salt varies from user to user.
My intent is to have the code - on a button.click event - check the Username and Password fields and return an error depending on which is wrong. Or if both are wrong, return a different error message. I've set the username as parts and the password as parts (still learning how to use external authentication). [Code]
The program is for users to submit their username by typing in their username and pressing the submit button. The username may be able to display on the Usernamelabel in form1.(I made the button on form2) I have problems coding to make the text to come out in form2.My code comes out as error.
Here is the code in form2. Public Class Form2
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
I have a role called "Customer", I wish to add users who register to be to automatically added to that role. At the moment I can only assign users to roles by using ASP.net Web Site Administration Tool.If it helps: I'm using the default login.aspx and register.aspx files from Account folder in vb web profile.
I am having a problem with my roles Identification. I am try to read all the roles for a given user. No matter what I try only the first role, only 1 role for the user is being returned. My code is as follows.
i'm having some problem over here..when user enter their id and password,it will show up the main page and its for user but when admin or staff enter their id,it will enter the user's main page and i have to click admin site on the top hyperlink where it automatically logout and once i enter back admin passwrd or staff passwrd then only it redirect to admin page or staff page.how to make it like once user enter their passwrd it redirect to user page and once admin enter admin password or staff enter their password in the login it redirect to admin or staff ?I have 3 roles over here which are admin,staff and user.Hereby i'll provide you my aspx code and also my vb code which is running behind the program.
I want the app to redirect a user to a different home page depending on their role. Its currently working for 2 users using the following IF?
If Request.IsAuthenticated AndAlso User.IsInRole("Staff") = True Then Response.Redirect("~/About.aspx") ElseIf Request.IsAuthenticated AndAlso User.IsInRole("HR") = False Then Response.Redirect("~/HRHRCompanyNavigation.aspx") End If
How can I get this to work for more than 2 user roles?
I'm trying to create a routine in my asp.net's main page that will see if the current user is a member of a Windows domain group. The site is hosted in IIS and is visible through our intranet.
GlenFerrieLive listed this code (which I'd like to use) in an earlier post: UserName = System.Environment.UserName If Roles.IsUserInRole(UserName, "MyDomainMyGroup") Then
[Code]....
Problem is, now I'm getting the configuration error 'Default Role Provider could not be found'.
How can I get around this? I just need to see if the current user exists in a specific domain group.
This desktop app written in VB.Net within VStudio 2008 fails when one of our "power users" tries to run the program: Select permission denied on object 'AcctLogon', database 'MDS', owner 'dbo'. The author of the app is out for a few weeks and I am the "fixer" while she's out. Both of our logins for SQL have permissions for db_owner in the MDS database but our user does not. The user has a Windows user login for this instance of SQL. This login has permissions for the public role only in the MDS database.
I am curious as to the proper technique to use SQL Server's AppRole with a LINQ to SQL Class. I understand I have to establish the intial connection with no connection pooling. However, do I simply call the SQL stored procedure sp_setapprole using standard LINQ before executing any of my methods that interact with the database, or is there a better way to enable and use AppRole within the LINQ to SQL class?
Iv'e been away from Visual Basic for the past 3 or 4 years so I am a bit vague on the details that I am looking for.
I got myself my first programming job at the company that I work for and I start Monday.
The company has little programming knowledge (well I assumed this as they said they do not have a dedicated programming IDE at my interview) and relies on ad-hoc VBA scripts to perform necessary processing on data. This is all fine and I can deal with that but there is a project that I wish to work on and I think a standalone dedicated application would be much better than extending Excel with VBA.
Now after being with the company for 10+ years, I know they are conservative at spending money so asking them to buy Visual Studio is not really an option so I'm going to suggest that instead of using VBA, I will design an application using Visual Basic Express.
All I need to know is, if there are any kind of limitation to database accessing with the express editions? (Iv'e only ever used OLEDB connected to small MS Access files) I do not know what type of database the company uses yet, but I do know they use ODBC to connect to it, and rely on Sage to do 90% of their work.
I'm creating a custom Role provider based on the ASP.NET Role provider. I have 3 tables. One for Users, one for Roles, one for UsersInRoles.The Users table has no password column because the users are authenticated with ActiveDirectory. That's my approach so far. I can't get the cusstom Role Provider to work, anyone has the same situation like me. How do you make a custom Role provider works with AD?