Beispiel #1
0
func getUserSID(username string) (string, error) {
	sid, _, _, e := syscall.LookupSID("", username)
	if e != nil {
		return "", e
	}
	sidStr, err := sid.String()
	return sidStr, err
}
Beispiel #2
0
// Lookup looks up a user by username.
func Lookup(username string) (*User, error) {
	sid, _, t, e := syscall.LookupSID("", username)
	if e != nil {
		return nil, e
	}
	if t != syscall.SidTypeUser {
		return nil, fmt.Errorf("user: should be user account type, not %d", t)
	}
	return newUserFromSid(sid)
}