views:

222

answers:

0

I just got my new work computer build all done and encountered a brand new error in our application when we are trying to set modify permissions. Everything used to work perfect in Vista and my old build.

The error: Some or all identity references could not be translated.

The line: dSecurity.SetAccessRule(rule)

The function:

Public Shared Sub SetModifyPermissions(ByVal vPath As String, ByVal UserName As String)
    ' set modify permissions
    If IO.Directory.Exists(vPath) Then

        Dim di As New DirectoryInfo(vPath)
        Dim dSecurity As AccessControl.DirectorySecurity = di.GetAccessControl()
        Dim rule As New AccessControl.FileSystemAccessRule(UserName, AccessControl.FileSystemRights.Modify, AccessControl.InheritanceFlags.None Or AccessControl.InheritanceFlags.ContainerInherit Or AccessControl.InheritanceFlags.ObjectInherit, AccessControl.PropagationFlags.None, AccessControl.AccessControlType.Allow)
        dSecurity.SetAccessRule(rule)
        di.SetAccessControl(dSecurity)

    End If
End Sub

Thanks