| 1 | package mstypes |
| 2 | |
| 3 | import ( |
| 4 | "encoding/binary" |
| 5 | |
| 6 | "gopkg.in/jcmturner/rpc.v0/ndr" |
| 7 | ) |
| 8 | |
| 9 | // GroupMembership implements https://msdn.microsoft.com/en-us/library/cc237945.aspx |
| 10 | // RelativeID : A 32-bit unsigned integer that contains the RID of a particular group. |
| 11 | // The possible values for the Attributes flags are identical to those specified in KERB_SID_AND_ATTRIBUTES |
| 12 | type GroupMembership struct { |
| 13 | RelativeID uint32 |
| 14 | Attributes uint32 |
| 15 | } |
| 16 | |
| 17 | // ReadGroupMembership reads a GroupMembership from the bytes slice. |
| 18 | func ReadGroupMembership(b *[]byte, p *int, e *binary.ByteOrder) GroupMembership { |
| 19 | r := ndr.ReadUint32(b, p, e) |
| 20 | a := ndr.ReadUint32(b, p, e) |
| 21 | return GroupMembership{ |
| 22 | RelativeID: r, |
| 23 | Attributes: a, |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | // DomainGroupMembership implements https://msdn.microsoft.com/en-us/library/hh536344.aspx |
| 28 | // DomainId: A SID structure that contains the SID for the domain.This member is used in conjunction with the GroupIds members to create group SIDs for the device. |
| 29 | // GroupCount: A 32-bit unsigned integer that contains the number of groups within the domain to which the account belongs. |
| 30 | // GroupIds: A pointer to a list of GROUP_MEMBERSHIP structures that contain the groups to which the account belongs in the domain. The number of groups in this list MUST be equal to GroupCount. |
| 31 | type DomainGroupMembership struct { |
| 32 | DomainID RPCSID |
| 33 | GroupCount uint32 |
| 34 | GroupIDs []GroupMembership // Size is value of GroupCount |
| 35 | } |
| 36 | |
| 37 | // ReadDomainGroupMembership reads a DomainGroupMembership from the bytes slice. |
| 38 | func ReadDomainGroupMembership(b *[]byte, p *int, e *binary.ByteOrder) (DomainGroupMembership, error) { |
| 39 | d, err := ReadRPCSID(b, p, e) |
| 40 | if err != nil { |
| 41 | return DomainGroupMembership{}, err |
| 42 | } |
| 43 | c := ndr.ReadUint32(b, p, e) |
| 44 | g := make([]GroupMembership, c, c) |
| 45 | for i := range g { |
| 46 | g[i] = ReadGroupMembership(b, p, e) |
| 47 | } |
| 48 | return DomainGroupMembership{ |
| 49 | DomainID: d, |
| 50 | GroupCount: c, |
| 51 | GroupIDs: g, |
| 52 | }, nil |
| 53 | } |