adclient

package
v0.1.17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 3, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package adclient interacts with AD domain controllers

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssignTemporaryPassword

func AssignTemporaryPassword(s Client, args PasswordArgs) (*string, error)

AssignTemporaryPassword will reset a users password with a temporary password that will be required to reset on login. There is no native way to have AD generate and reset with a password. It must be supplied by the admin during reset time. We figure out what password policy applies to the user and make a password according to the policy. We always operate on the assumption that `ComplexityEnabled` is true. This means the password has to have at least 3 out of Uppercase, Lowercase, Number, Special Characters.

func GetADUserGroups

func GetADUserGroups(s Client, user *User) (*[]UserGroup, error)

GetADUserGroups returns AD user groups from the domain

func IsAccountLocked

func IsAccountLocked(s Client, args UnlockArgs) (*bool, error)

IsAccountLocked will return a boolean indicating account lockout status

func UnlockAccount

func UnlockAccount(s Client, args UnlockArgs) error

UnlockAccount will unlock a user account

Types

type ADGroup

type ADGroup struct {
	Name       string `json:"Name"`
	ObjectGUID string `json:"ObjectGUID"`
}

ADGroup represents ADGroup membership info

type ADGroups

type ADGroups []*ADGroup

ADGroups is a list of ADGroup

func GetADGroups

func GetADGroups(s Client, args GetADGroupArgs) (*ADGroups, *string, error)

GetADGroups retrieves groups from AD.

type Client

type Client interface {
	Execute(cmd string) (string, error)
	Close() error
}

Client is the interface adapted by the client used for AD connection

func New

func New() (Client, error)

New returns a new client

type Domain

type Domain struct {
	Forest      string `json:"Forest"`
	NetBIOSName string `json:"NetBIOSName"`
	DNSRoot     string `json:"DNSRoot"`
	Name        string `json:"Name"`
}

Domain represents the domain response

func GetADDomain

func GetADDomain(s Client) (*Domain, error)

GetADDomain returns domain information

type GetADGroupArgs

type GetADGroupArgs struct {
	NamePrefix *string
	MaxCount   *int64
	Cursor     *string
}

GetADGroupArgs is a struct of request args

type GetADUserArgs

type GetADUserArgs struct {
	Identity string
}

GetADUserArgs is an requests args to user functions

type ListADUsersArgs

type ListADUsersArgs struct {
	UpdatedAfter *time.Time
	Cursor       *string
}

ListADUsersArgs is request args to user functions

type MockClient

type MockClient struct {
	ResponseMap map[string]Response
}

MockClient is used for test cases. You can define the response for a query to powershell here.

func (*MockClient) Close

func (s *MockClient) Close() error

Close terminates the connection

func (*MockClient) Execute

func (s *MockClient) Execute(cmd string) (string, error)

Execute runs the command

type PasswordArgs

type PasswordArgs struct {
	UserImmutableID string
}

PasswordArgs is the args to password functions

type PasswordPolicy

type PasswordPolicy struct {
	MinPasswordLength *int `json:"MinPasswordLength,omitempty"`
}

PasswordPolicy is the representation of the policy in the system

func GetPasswordPolicy

func GetPasswordPolicy(s Client, immutableID string) (*PasswordPolicy, error)

GetPasswordPolicy gets a password policy that applies to the given user. It checks if the user is a member of any password policy groups and returns the one with the lowest precedence. If there are no groups the user is a member one then the default password policy is retrieved.

type PowershellClient

type PowershellClient struct {
	// contains filtered or unexported fields
}

PowershellClient is used for invoking commands in an underlying powershell process.

func (*PowershellClient) Close

func (s *PowershellClient) Close() error

Close terminates the connection

func (*PowershellClient) Execute

func (s *PowershellClient) Execute(cmd string) (string, error)

Execute runs the cmd

type Response

type Response struct {
	Stdout string
	Err    error
}

Response indicates the return struct

type UnlockArgs

type UnlockArgs struct {
	UserImmutableID string
}

UnlockArgs is request arguments to unlock functions

type User

type User struct {
	SamAccountName    string      `json:"SamAccountName"`
	DistinguishedName string      `json:"DistinguishedName"`
	Name              string      `json:"Name"`
	EmailAddress      string      `json:"EmailAddress"`
	EmployeeID        interface{} `json:"EmployeeID"`
	ObjectGUID        string      `json:"ObjectGUID"`
	MemberOf          []string    `json:"MemberOf"`
	LockedOut         bool        `json:"LockedOut"`
	WhenChanged       string      `json:"whenChanged"`
}

User is info from AD on a certain user

type UserGroup

type UserGroup struct {
	Name       string `json:"Name"`
	ObjectGUID string `json:"ObjectGUID"`
}

UserGroup is info for user groups

type Users

type Users []*User

Users is a list os User

func GetADUser

func GetADUser(s Client, args GetADUserArgs) (*Users, error)

GetADUser retrieved user information form AD

func ListADUsers

func ListADUsers(s Client, args ListADUsersArgs) (*Users, *string, error)

ListADUsers lists ad users according to specified args

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL