Dobry den, resim nasledujici problem. Mam aplikaci v VB.NET, ktera bezproblemu prideluje prava uzivatelum (uzivatele ve Windows 7) k pristupu k nejakemu adresari. Vse funguje v pohode, pokud aplikaci spusti clovek, ktery ma prava pro zmenu prav. Potrebuji, aby kdyz aplikaci spusti uzivatel, ktere tyto prava nema, aby presto aplikace mohla tato pristupova prava zmenit. Muzete mi nekdo poradit jak na to jit? Nize prikladam kod, ktery pouzivam pro pridelovani a odebirani prav
Sub AddDirectorySecurity(ByVal FileName As String, ByVal Account As String, ByVal Rights As FileSystemRights, ByVal ControlType As AccessControlType)
Dim dInfo As New DirectoryInfo(FileName)
Dim dSecurity As DirectorySecurity = dInfo.GetAccessControl()
dSecurity.AddAccessRule(New FileSystemAccessRule(Account, Rights, InheritanceFlags.ContainerInherit Or InheritanceFlags.ObjectInherit, PropagationFlags.None, ControlType))
dInfo.SetAccessControl(dSecurity)
End Sub
Sub RemoveDirectorySecurity(ByVal FileName As String, ByVal Account As String, ByVal Rights As FileSystemRights, ByVal ControlType As AccessControlType)
Dim dInfo As New DirectoryInfo(FileName)
Dim dSecurity As DirectorySecurity = dInfo.GetAccessControl()
dSecurity.RemoveAccessRule(New FileSystemAccessRule(Account, Rights, InheritanceFlags.ContainerInherit Or InheritanceFlags.ObjectInherit, PropagationFlags.None, ControlType))
dInfo.SetAccessControl(dSecurity)
End Sub
|