Documentation ¶
Index ¶
- func GetString(v interface{}) string
- func SanitiseString(key string) string
- func SanitiseTFInput(d *schema.ResourceData, key string) string
- func SetMachineExtensionNames(client *winrm.Client, gpoDN, value string, execLocally bool) error
- func SortInnerSlice(m map[string]interface{}) map[string]interface{}
- type PSOutput
- type PowerShell
- type SID
- type User
- type WinRMResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SanitiseString ¶
SanitiseString returns the value of a string after some basic sanitisation checks to protect ourselves from command injection
func SanitiseTFInput ¶
func SanitiseTFInput(d *schema.ResourceData, key string) string
SanitiseTFInput returns the value of a resource field after passing it through SanitiseString
func SetMachineExtensionNames ¶
SetMachineExtensionName will add the necessary GUIDs to the GPO's gPCMachineExtensionNames attribute. These are required for the security settings part of a GPO to work.
func SortInnerSlice ¶
custom attributes can be single valued or multi valued. Multi-value attribute values are represented by a json array that gets converted to a list. It's not guaranteed that the order of the values returned by windows will match the order set by the user in the config, so we just check the members of the custom attributes map and if a slice is found then it's sorted before we compare it.
Types ¶
type PSOutput ¶
type PSOutput struct {
PSStrings []psString `xml:"S"`
}
PSOutput is used to unmarshall CLIXML output Right now we are only using this to extract error messages, but it can be extended to unpack more elements if required.
type PowerShell ¶
type PowerShell struct {
// contains filtered or unexported fields
}
PowerShell struct
func (*PowerShell) ExecutePScmd ¶
func (p *PowerShell) ExecutePScmd(args ...string) (stdout string, stderr string, exitCode int, err error)
ExecutePScmd will execute the powershell command using exec
type SID ¶
type SID struct {
Value string `json:"Value"`
}
SID is a common structure by all "security principals". This means domains, users, computers, and groups. The structure we get from powershell contains more fields, but we're only interested in the Value.
type User ¶
type User struct { GUID string `json:"ObjectGUID"` SAMAccountName string `json:"SamAccountName"` PrincipalName string `json:"UserPrincipalName"` City string Company string Country string Department string Description string DisplayName string `json:"DisplayName"` DistinguishedName string `json:"DistinguishedName"` Division string EmailAddress string EmployeeID string EmployeeNumber string Enabled bool Fax string GivenName string HomeDirectory string HomeDrive string HomePhone string HomePage string Initials string MobilePhone string Office string OfficePhone string Organization string OtherName string POBox string PostalCode string SID SID `json:"SID"` SmartcardLogonRequired bool State string StreetAddress string Surname string Title string TrustedForDelegation bool UserAccountControl int64 `json:"userAccountControl"` Password string Container string Domain string Username string PasswordNeverExpires bool CannotChangePassword bool CustomAttributes map[string]interface{} }
User represents an AD User
func GetUserFromHost ¶
func GetUserFromHost(client *winrm.Client, guid string, customAttributes []string, execLocally bool) (*User, error)
GetUserFromHost returns a User struct based on data retrieved from the AD Domain Controller.
func GetUserFromResource ¶
func GetUserFromResource(d *schema.ResourceData) (*User, error)
GetUserFromResource returns a user struct built from Resource data
func (*User) DeleteUser ¶
DeleteUser deletes an AD user by calling Remove-ADUser
func (*User) ModifyUser ¶
ModifyUser updates the AD user's details based on what's changed in the resource.
type WinRMResult ¶
WinRMResult holds the stdout, stderr and exit code of a powershell command
func RunWinRMCommand ¶
func RunWinRMCommand(conn *winrm.Client, cmds []string, json bool, forceArray bool, execLocally bool) (*WinRMResult, error)
RunWinRMCommand will run a powershell command and return the stdout and stderr The output is converted to JSON if the json patameter is set to true.