mirror of
https://github.com/rwinkhart/sys.git
synced 2026-08-28 04:46:44 -04:00
windows: add support for creating well known SIDs
The security API is already quite extensive, but for some strange reason, this essential and useful function was left out of the initial port. So, we add it here, along with the relevant constants and a test case. Change-Id: I99568703565addf15603480f11b0edafdfc1718f Reviewed-on: https://go-review.googlesource.com/c/sys/+/167378 Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Run-TryBot: Alex Brainman <alex.brainman@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
committed by
Alex Brainman
parent
fead790013
commit
a2f829d7f3
@@ -90,3 +90,17 @@ func TestTOKEN_ALL_ACCESS(t *testing.T) {
|
||||
t.Errorf("TOKEN_ALL_ACCESS = %x, want 0xF01FF", windows.TOKEN_ALL_ACCESS)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreateWellKnownSid(t *testing.T) {
|
||||
sid, err := windows.CreateWellKnownSid(windows.WinBuiltinAdministratorsSid)
|
||||
if err != nil {
|
||||
t.Fatalf("Unable to create well known sid for administrators: %v", err)
|
||||
}
|
||||
sidStr, err := sid.String()
|
||||
if err != nil {
|
||||
t.Fatalf("Unable to convert sid into string: %v", err)
|
||||
}
|
||||
if sidStr != "S-1-5-32-544" {
|
||||
t.Fatalf("Expecting administrators to be S-1-5-32-544, but found %s instead", sidStr)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user