DanysysTeam / PS-SFTA

PowerShell Set File Type Association
253 stars 53 forks source link

Get SID of the current user #7

Closed Larpico closed 2 years ago

Larpico commented 2 years ago

The current method of retrieving the current user Security Identifier doesn't work for domain-joined computers when there are local users accounts and domain user accounts with the same name. The SID of the local account is always returned.

This PR uses System.DirectoryServices.AccountManagement.

Danyfirex commented 2 years ago

Thank you @Larpico. I was thinking in add it as an optional parameter due to in my tests calling getting SID using System.DirectoryServices.AccountManagement in a not domain-joined machine and it takes few seconds for returning the user SID. But I think that delay will not affect the script's performance/functionality, so It's merged now.

Danyfirex commented 2 years ago

@Larpico I'm thinking in revert the change and add the feature in a special case where use can define/set from code with a switch maybe because when I set multiples application (for example 3) at once it take much time(15-20 seconds in my tests). probably we could check if It's in a domain with the issue you faced it and handle it.