Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. .NET Security Question

.NET Security Question

Scheduled Pinned Locked Moved Visual Basic
questioncsharpsysadminsecurityxml
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mlauahi
    wrote on last edited by
    #1

    I have attempted to use some of the new security classes in .NET 2.0. Question. How can I check the writes of the currently logged in user for a given resource suce as a file/directory. I want to know before taking an action if a user can write to a directory, can the user create a sub directory in a given directory on the network. Here is what I have tried: PUBLIC FUNCTION ReturnCheckMyRightsOnDirectory(XRightsToCheck AS DirectoryPermissions , XPath AS STRING) AS BOOLEAN IF MY.Computer.FileSystem.DirectoryExists(XPath) = FALSE THEN RETURN FALSE END IF TRY DIM DirectoryName AS STRING = XPath Dim dInfo AS NEW DirectoryInfo(DirectoryName) Dim dSecurity As DirectorySecurity = dInfo.GetAccessControl() DIM DirectoryRightToCheck AS FileSystemRights SELECT CASE XRightsToCheck CASE DirectoryPermissions.Create DirectoryRightToCheck = FileSystemRights.CreateDirectories CASE DirectoryPermissions.Read DirectoryRightToCheck = FileSystemRights.Read CASE DirectoryPermissions.Update DirectoryRightToCheck = FileSystemRights.Modify CASE DirectoryPermissions.Delete DirectoryRightToCheck = FileSystemRights.Delete CASE DirectoryPermissions.Write DirectoryRightToCheck = FileSystemRights.Write CASE DirectoryPermissions.Execute DirectoryRightToCheck = FileSystemRights.ExecuteFile CASE DirectoryPermissions.Admin DirectoryRightToCheck = FileSystemRights.FullControl END SELECT dSecurity.AddAccessRule(New FileSystemAccessRule(SystemUserName, DirectoryRightToCheck, AccessControlType.Allow)) dInfo.SetAccessControl(dSecurity) RETURN TRUE CATCH ex As Exception RETURN FALSE END TRY END FUNCTION

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups