Visual Basic Developer Center > Visual Basic Forums > Visual Basic Language > howto: vb.net set group rights to a network file
Ask a questionAsk a question
 

Questionhowto: vb.net set group rights to a network file

  • Friday, July 15, 2005 5:06 PMSupport Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hello:
    using whidbey, vb.net,
    I am impersonating a domain admin
    I have retrieved from AD a group called: "oci\School Reporting Authentication:
    I call the following:
    1) I impersonate a domain admin
    2) I open a dialog box and go to the file on the win 2003 server that the Impersonated account has admin rights on
    3) I call the following
    ----------------------------------------------------------------------

    Dim user As String = "oci\School Reporting Authentication"
    Dim mSec As New EventWaitHandleSecurity()
    Dim rule = New EventWaitHandleAccessRule(user, EventWaitHandleRights.ReadPermissions, AccessControlType.Allow)
    Try
       mSec.AddAccessRule(rule)
    Catch ex As Security.Authentication.InvalidCredentialException

    Form1.lblFilename.Text = Form1.lblFilename.Text + vbCrLf + "exception assigning rule:" + ex.Message
    End Try

    Form1.lblFilename.Text = Form1.lblFilename.Text + vbCrLf + "Are access Rules Protected ?:" + mSec.AreAccessRulesProtected.ToString()

    mSec = Nothing
    ----------------------------------------------------------------------
    There are no errors and the new group "wont take" - nothing happens.

    Question: is this approach using EventWaitHandleSecurity() correct or is there a better one?
    Thanks
    Support