Home All Groups Group Topic Archive Search About

Creating Folders and Security

Author
25 Aug 2006 9:23 AM
Vayse
Hi
On the company server, there is a folder for each client. This folder should
be named after the Clients 6 digiit ID.
At the moment, the folders are created manually by users. Of course, this
leads to errors.
So I'd like to write a program that creates the folder. Just use
My.Computer.FileSystem.CreateDirectory will work fine, except for one issue.
I want to change the permissions on the server so that users can't create
folders manually. This also means the program won't work.
Is there something in VB that I have the program use admin permissions, so
that it will create the folder irrespective of the users rights?

Thanks
Vayse

Author
25 Aug 2006 11:50 AM
Jared
You can't override the security mechanisms of Windows, but, you can use
impersonation with an account with sufficient permissions to create the
directories.

Look into the System.Security.Principal.WindowsImpersonationContext class. 
There are a ton of example online.

Jared

Show quoteHide quote
"Vayse" wrote:

> Hi
> On the company server, there is a folder for each client. This folder should
> be named after the Clients 6 digiit ID.
> At the moment, the folders are created manually by users. Of course, this
> leads to errors.
> So I'd like to write a program that creates the folder. Just use
> My.Computer.FileSystem.CreateDirectory will work fine, except for one issue.
> I want to change the permissions on the server so that users can't create
> folders manually. This also means the program won't work.
> Is there something in VB that I have the program use admin permissions, so
> that it will create the folder irrespective of the users rights?
>
> Thanks
> Vayse
>
>
>
Author
25 Aug 2006 3:53 PM
Spam Catcher
"Vayse" <vayse@deadspam.com> wrote in
news:O9Z4XgCyGHA.2400@TK2MSFTNGP03.phx.gbl:

> Is there something in VB that I have the program use admin
> permissions, so that it will create the folder irrespective of the
> users rights?

Use impersonation to impersonate an admin account to set the folder
security.