Hi @Frangky Bunga ,
This error is usually caused by trying to set an access control list using incorrect user identifiers (identity references).
You can try converting the user name to a security identifier (SID) and then passing it to the FileSystemAccessRule constructor.
This ensures that you are using a valid security identifier, regardless of whether the current user is a local user or a domain user. Using SIDs avoids errors caused by incorrect user name formatting or non-existent users.
Also as RLWA32 mentioned, make sure that the current user has permission to modify ACLs.
Dim UserAccountSid As SecurityIdentifier = New NTAccount(UserAccount).Translate(GetType(SecurityIdentifier))
Dim FolderAcl As New DirectorySecurity
FolderAcl.AddAccessRule(New FileSystemAccessRule(UserAccountSid, FileSystemRights.Modify, InheritanceFlags.ContainerInherit Or InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Allow))
Best Regards.
Jiachen Li
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.