Folder permissions VB 2005

Discussion in 'ASP .Net Security' started by philg1984, Feb 3, 2006.

  1. philg1984

    philg1984 Guest

    Hi, I am trying to create a named folder using VB2005 and then set
    permissions for this folder for a new user i want to create using just code.
    I have searched and not found any code which works. Any ideas? Thanks
    philg1984, Feb 3, 2006
    #1
    1. Advertising

  2. Hello Phil,

    what exactly do you want to do?
    1. Create a folder
    2. Set permission on that folder
    3. Create a new user?
    4. Set permission on the folder for the newly created user?

    Greetings,
    Henning

    "philg1984" <> wrote in message
    news:...
    > Hi, I am trying to create a named folder using VB2005 and then set
    > permissions for this folder for a new user i want to create using just
    > code.
    > I have searched and not found any code which works. Any ideas? Thanks
    Henning Krause [MVP], Feb 3, 2006
    #2
    1. Advertising

  3. philg1984

    philg1984 Guest

    Thats right. Thanks.

    "Henning Krause [MVP]" wrote:

    > Hello Phil,
    >
    > what exactly do you want to do?
    > 1. Create a folder
    > 2. Set permission on that folder
    > 3. Create a new user?
    > 4. Set permission on the folder for the newly created user?
    >
    > Greetings,
    > Henning
    >
    > "philg1984" <> wrote in message
    > news:...
    > > Hi, I am trying to create a named folder using VB2005 and then set
    > > permissions for this folder for a new user i want to create using just
    > > code.
    > > I have searched and not found any code which works. Any ideas? Thanks

    >
    >
    >
    philg1984, Feb 3, 2006
    #3
  4. Hello,

    the correct order would be this:

    1. Create the new user
    2. Prepare a DirectorySecurity and populate it with the necessary entries
    3. Call Directory.CreateDirectory(directory, security) to create the
    directory with the security settings.

    The first step is the tricky one and depends whether you want to create a
    local user or a user in Actice Directory.
    To create a local user, see
    http://support.microsoft.com/default.aspx?scid=kb;en-us;306271
    To create a user in AD, see
    http://www.irishdev.com/blogs/jbrennan/archive/2005/02/01/455.aspx.

    Once created you can use the NtAccount class to create your
    DirectorySecurity:
    NTAccount account = new NtAccount(username);
    DirectorySecurity sec = new DirectorySecurity();
    sec.SetAccessRule(new FileSystemRule(account, FileSystemRights.Read,
    AccessControlType.Allow));
    // Set the other necessary access rules

    Directory.CreateDirectory(name, sec);

    Greetings,
    Henning Krause


    "philg1984" <> wrote in message
    news:...
    > Thats right. Thanks.
    >
    > "Henning Krause [MVP]" wrote:
    >
    >> Hello Phil,
    >>
    >> what exactly do you want to do?
    >> 1. Create a folder
    >> 2. Set permission on that folder
    >> 3. Create a new user?
    >> 4. Set permission on the folder for the newly created user?
    >>
    >> Greetings,
    >> Henning
    >>
    >> "philg1984" <> wrote in message
    >> news:...
    >> > Hi, I am trying to create a named folder using VB2005 and then set
    >> > permissions for this folder for a new user i want to create using just
    >> > code.
    >> > I have searched and not found any code which works. Any ideas? Thanks

    >>
    >>
    >>
    Henning Krause [MVP], Feb 3, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dante
    Replies:
    0
    Views:
    345
    Dante
    May 11, 2004
  2. Jason
    Replies:
    0
    Views:
    413
    Jason
    May 13, 2004
  3. Scott Allen
    Replies:
    0
    Views:
    421
    Scott Allen
    Jul 13, 2004
  4. ralderton

    Folder Permissions

    ralderton, Aug 6, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    10,422
    Jeffrey Tan[MSFT]
    Aug 7, 2004
  5. Curt K
    Replies:
    0
    Views:
    548
    Curt K
    Nov 3, 2006
Loading...

Share This Page