473,385 Members | 1,647 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

security using windowsprincipal class

Hi,

I'm trying to get my application to authenticate using role based when the
user runs the application.

When the user logs on and is in the security group "school", the user gets
into the application no problem. But when the user is removed from the
group but doesnt log back in, he still has permissions to run the
application. This is also true if the user is already logged on and then
placed in the security group, the user cannot run the application. Is there
a way to make the application check Active Directory without logging in and
logging out for the permissions to take effect?

I need this to work because I cant iterate thru Active Directory to get the
nested security groups/roles of the user.

thanks in advance,
Will

Code:
Try

AppDomain.CurrentDomain.SetPrincipalPolicy(Princip alPolicy.WindowsPrincipal)

'get the current userid domain\username

Dim MyPrincipal As WindowsPrincipal = CType(Thread.CurrentPrincipal,
WindowsPrincipal)

winPrincipal = New WindowsPrincipal(MyPrincipal.Identity)

'get the current userid

userid = MyPrincipal.Identity.Name

Dim pp As New PrincipalPermission(userid, adrole)

pp.Demand()

'check if the user is part of the role to access this application

If winPrincipal.IsInRole(adrole) Then

'get the userid without the domain

userid = Mid(userid, InStr(userid, "\") + 1)

UserInfoClass.UserIdent = userid

Return True

Else

MsgBox("You do not have permission to run this program. Please see your
administrator.", MsgBoxStyle.Exclamation, "Access Error")

Return False

'Me.Close()

End If

Catch ex As Exception

MsgBox("Error:" & ex.Message)

Return False

End Try
Feb 13 '07 #1
0 1278

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Chris | last post by:
Hi, Regarding : Role based Security Scenario : On W2K, I'm currently logged in as 'user1' Checking the properties of the user account 'user1' : --> Start/Programs/Administrative...
1
by: Greg Busby | last post by:
I have a client who wants to use Windows Integrated Security for authentication and authorization to use this application. They also want this application to run as soon as Windows comes up. So, I...
12
by: Angelos Karantzalis | last post by:
Is there a way to set Permissions based on user roles by using some configuration file for my application ? I'm coming from a Java background, where that could very easily be accomplished but...
0
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. ...
1
by: Adam Gentry | last post by:
Let's try this again... Is there any current functionality in C# to access windows authentication in a windows application (not ASP) without using unmanaged code? I would appreciate if anyone...
1
by: localhost | last post by:
I have decorated several classes and methods in an ASP.NET appliation with declarative security attributes for roles. For example: I currently use a Try...Finally block in calling code to...
1
by: Paul | last post by:
I was working with a VB book that was going over the Security stuff in VBNet, and I can't seem to get their code to work. I modified it and I can't seem to get it to work either. I am running...
1
by: Ray Cassick \(Home\) | last post by:
I am having a bit of a problem doing something that I was expecting to be very straight forward. I am trying to declare a Role that needs to be available before a specific class can be...
3
by: Ray Cassick \(Home\) | last post by:
I have some code that looks like this for one of my classes: Imports System.Security Imports System.Security.Permissions Imports System.Security.Principal ...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.