-
Notifications
You must be signed in to change notification settings - Fork 242
/
kerb_sid_and_attributes.go
42 lines (36 loc) · 1.2 KB
/
kerb_sid_and_attributes.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package mstypes
import (
"encoding/binary"
"gopkg.in/jcmturner/rpc.v0/ndr"
)
// Attributes of a security group membership and can be combined by using the bitwise OR operation.
// They are used by an access check mechanism to specify whether the membership is to be used in an access check decision.
const (
SEGroupMandatory = 31
SEGroupEnabledByDefault = 30
SEGroupEnabled = 29
SEGroupOwner = 28
SEGroupResource = 2
//All other bits MUST be set to zero and MUST be ignored on receipt.
)
// KerbSidAndAttributes implements https://msdn.microsoft.com/en-us/library/cc237947.aspx
type KerbSidAndAttributes struct {
SID RPCSID // A pointer to an RPC_SID structure.
Attributes uint32
}
// ReadKerbSidAndAttributes reads a KerbSidAndAttribute from the bytes slice.
func ReadKerbSidAndAttributes(b *[]byte, p *int, e *binary.ByteOrder) (KerbSidAndAttributes, error) {
s, err := ReadRPCSID(b, p, e)
if err != nil {
return KerbSidAndAttributes{}, err
}
a := ndr.ReadUint32(b, p, e)
return KerbSidAndAttributes{
SID: s,
Attributes: a,
}, nil
}
// SetFlag sets a flag in a uint32 attribute value.
func SetFlag(a *uint32, i uint) {
*a = *a | (1 << (31 - i))
}