package pac

import (
	

	
)

// UPNDNSInfo implements https://msdn.microsoft.com/en-us/library/dd240468.aspx
type UPNDNSInfo struct {
	UPNLength           uint16 // An unsigned 16-bit integer in little-endian format that specifies the length, in bytes, of the UPN field.
	UPNOffset           uint16 // An unsigned 16-bit integer in little-endian format that contains the offset to the beginning of the buffer, in bytes, from the beginning of the UPN_DNS_INFO structure.
	DNSDomainNameLength uint16
	DNSDomainNameOffset uint16
	Flags               uint32
	UPN                 string
	DNSDomain           string
}

const (
	upnNoUPNAttr = 31 // The user account object does not have the userPrincipalName attribute ([MS-ADA3] section 2.349) set. A UPN constructed by concatenating the user name with the DNS domain name of the account domain is provided.
)

// Unmarshal bytes into the UPN_DNSInfo struct
func ( *UPNDNSInfo) ( []byte) ( error) {
	//The UPN_DNS_INFO structure is a simple structure that is not NDR-encoded.
	 := mstypes.NewReader(bytes.NewReader())
	.UPNLength,  = .Uint16()
	if  != nil {
		return
	}
	.UPNOffset,  = .Uint16()
	if  != nil {
		return
	}
	.DNSDomainNameLength,  = .Uint16()
	if  != nil {
		return
	}
	.DNSDomainNameOffset,  = .Uint16()
	if  != nil {
		return
	}
	.Flags,  = .Uint32()
	if  != nil {
		return
	}
	 := mstypes.NewReader(bytes.NewReader([.UPNOffset : .UPNOffset+.UPNLength]))
	 := mstypes.NewReader(bytes.NewReader([.DNSDomainNameOffset : .DNSDomainNameOffset+.DNSDomainNameLength]))

	 := make([]rune, .UPNLength/2, .UPNLength/2)
	for  := 0;  < len(); ++ {
		var  uint16
		,  = .Uint16()
		if  != nil {
			return
		}
		[] = rune()
	}
	.UPN = string()
	 := make([]rune, .DNSDomainNameLength/2, .DNSDomainNameLength/2)
	for  := 0;  < len(); ++ {
		var  uint16
		,  = .Uint16()
		if  != nil {
			return
		}
		[] = rune()
	}
	.DNSDomain = string()

	return
}