473,385 Members | 2,015 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.

Controlling Read/Write Permissions Per User

I'm writing a Windows Forms app (connecting to SQL Server db) that will need
to enable/disable access to various UI controls based on the particular user
that is currently logged in.

My question:
What are some of the building blocks that I should look to use? E.g., how do
I know who the current user is? Should I create some custom class that has a
"CurrentUserID" property and then at runtime in Form_Load set the UI control
properties based on the value of the property? Is there some less "home
grown" way I should be looking to accomplish this - perhaps some features
built into the Framework?

Thanks!
May 25 '06 #1
1 1701
You will need to use the System.Security.Principal namespace. To get the
WindowsPrincipal instance for the current user, you call:

WindowsPrincipal wp = new WindowsPrincipal(WindowsIdentity.GetCurrent());

The WindowsPrincipal class has a member of type IIdentity, called Identity.
This provides all the information you need to know about the current user.
See
http://msdn2.microsoft.com/en-us/lib...iidentity.aspx
for details.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

If the truth hurts, wear it.
"Jeremy S." <A@B.COM> wrote in message
news:%2******************@TK2MSFTNGP02.phx.gbl...
I'm writing a Windows Forms app (connecting to SQL Server db) that will
need to enable/disable access to various UI controls based on the
particular user that is currently logged in.

My question:
What are some of the building blocks that I should look to use? E.g., how
do I know who the current user is? Should I create some custom class that
has a "CurrentUserID" property and then at runtime in Form_Load set the UI
control properties based on the value of the property? Is there some less
"home grown" way I should be looking to accomplish this - perhaps some
features built into the Framework?

Thanks!

May 25 '06 #2

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

Similar topics

1
by: Brett | last post by:
We have an application where the iusr_<srvr> has write NTFS permissions to a folder under the wwwroot (i.e. wwwroot\folder) and also there is a SQL Server database where we must give the...
7
by: Graham Taylor | last post by:
I've tried posting this in the 'microsoft.public.access' but I will post it here also, as I think it might be the webserver which is causing my problem. --------- I have an Access 2003 database...
7
by: TechBoy | last post by:
RE: Access 2002 SP3 I have an app "App1.mdb" that has internal security built-in via a table: tblSecurity. In this table a match is obtained to see if they are authorized to use the app. This...
0
by: Bob Weiner | last post by:
Hi, I'm looking at creating an account management system for our Windows AD and have a generic OO design question. I have a user class (user.cs) which will serve two purposes. First, it will...
6
by: Juan Manuel Ramollino | last post by:
Greetings everyone! I am creating a webcontrol that reads one or more directorie's content and displays all the filenames (tipically PDFs or PPTs) so that the user can select the desired one and...
5
by: Mitchell S. Honnert | last post by:
Is there a way, given the full path of a folder on a network, that one can programatically tell if you have Read access to that folder? I have an application where the user is able to select a...
2
by: rrossney | last post by:
Please look at the "what I've already done" section of this message before responding to it: I believe that I've done everything that the people who experience this error are typically told to do....
8
by: paquer | last post by:
Database Users need to have Read/Write etc... permissions to the folder where the Database resides in order to create the lock file. I have read only users. I have set up the Shortcut that links...
3
by: eholz1 | last post by:
Hello PHP Group, I am having trouble setting permissions correctly so that the magickwand api (php 5.2) can read and write images. I usually read a file from one directory, create a magickwand...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.