Shell API to get Windows SID from Cygwin name?

Allen, Norton T. allen@huarp.harvard.edu
Sat Sep 23 00:15:30 GMT 2023


On 9/22/2023 8:07 AM, Brian Inglis via Cygwin wrote:
> On 2023-09-21 23:58, Martin Wege via Cygwin wrote:
>> Does Cygwin have a shell (e.g. bash) API to lookup the Windows SID for
>> a given Cygwin user or group name?
>> /usr/bin/getent usersid thisisausername
>
> Forget Windows! Think Unix:
>
> $ getent passwd $USER    # sanitized output:
> $USER:*:$UID:545:U-$HOSTNAME/$USER,S-1-5-21-...-...-...-1001:$HOME:/bin/bash 
>
>
According to the man page, getent passwd takes a numeric UID, not a user 
name. But if you don't provide a UID, it basically lists what would be 
in /etc/passwd, which you could parse to locate the row you want by 
username.




More information about the Cygwin mailing list