Bonjour,
Je sui en train de développer une appli pour laquelle elle doit modifier les droits NTFS d'un dossier. Mais quand je lance l'appli, et rajoute bien l'utilisateur dans la liste des accès NTFS mais elle applique un droit "special". Voici le code et une impression ecran pour mieux identiifer mon souci.
Merci de votre aide.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 
    Sub Acl_folder(ByVal Tfolder, ByVal Tuser)
        Try
 
            ' Add the access control entry to the file.
            AddDirectorySecurity(Tfolder, Tuser, _
            FileSystemRights.Write, AccessControlType.Allow)
 
        Catch e As Exception
            Console.WriteLine(e)
        End Try
    End Sub
 
    Sub AddDirectorySecurity(ByVal FileName As String, ByVal Account As String, ByVal Rights As FileSystemRights, ByVal ControlType As AccessControlType)
        ' Create a new DirectoryInfoobject.
        Dim dInfo As New DirectoryInfo(FileName)
        'Dim heritage As InheritanceFlags
        'Dim propagationheritage As PropagationFlags
 
        ' Get a DirectorySecurity object that represents the 
        ' current security settings.
        Dim dSecurity As DirectorySecurity = dInfo.GetAccessControl()
 
        ' Add the FileSystemAccessRule to the security settings. 
        dSecurity.AddAccessRule(New FileSystemAccessRule(Account, Rights, ControlType))
 
 
        ' Set the new access settings.
        dInfo.SetAccessControl(dSecurity)
 
    End Sub
Nom : pb ntfs.JPG
Affichages : 212
Taille : 46,3 Ko
Ce code est issu de chez Microsoft :
http://msdn2.microsoft.com/en-us/lib...ysecurity.aspx

Pour info, j'utilise windows XP Pro SP2 avec Microsoft basic Expression edition 2005.