active_directory

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GeneralizedTimeToTime

func GeneralizedTimeToTime(val string) (time.Time, error)

func Integer8ToTime

func Integer8ToTime(val int64) time.Time

Types

type Ad struct {
	Name                 string    `ldap:"name"`
	DistinguishedName    string    `ldap:"distinguishedName"`
	DnsName              string    `ldap:"dNSHostName"`
	Created              time.Time `ldap:"whenCreated"`
	LastLogon            time.Time `ldap:"lastLogon"`
	LastPassword         time.Time `ldap:"pwdLastSet"`
	Description          []string  `ldap:"description"`
	Location             string    `ldap:"location"`
	ManagedBy            string    `ldap:"managedBy"`   // This is returned by the computer object and used to query the related user
	ManagedByCn          string    `ldap:"cn"`          // This is obtained by a second query for the managedBy user
	ManagedByGid         string    `ldap:"siemens-gid"` // This is obtained by a second query for the managedBy user
	ManagedByDepartment  string    `ldap:"department"`  // This is obtained by a second query for the managedBy user
	Os                   string    `ldap:"operatingSystem"`
	OsVersion            string    `ldap:"operatingSystemVersion"`
	ServicePrincipalName []string  `ldap:"servicePrincipalName"`
	CriticalObject       bool      `ldap:"isCriticalSystemObject"`
}

func AdodbQuery

func AdodbQuery(logger utils.Logger, searchCn string, searchDomain string) *Ad

AdodbQuery queries the given Active Directory service with implicit Windows authentication and returns a pointer to a populated Ad struct. ATTENTION: Make sure searchCn / ldapAddress are sanitized if taken from user input, to avoid SQL injection attacks!

func LdapQuery

func LdapQuery(
	logger utils.Logger,
	searchCn string,
	ldapAddress string,
	ldapPort int,
	ldapDomain string,
	ldapUser string,
	ldapPassword string,
	disableGssapi bool,
	dialTimeout time.Duration,
) *Ad

LdapQuery queries the given Active Directory service with explicit authentication and returns a pointer to a populated Ad struct. ATTENTION: Make sure searchCn / ldapAddress are sanitized if taken from user input, to avoid SQL injection attacks!

type Cache added in v1.0.3

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

Cache stores domain controller (dc) and key distribution centers (kdc) per domain/realm with TTL management.

func (*Cache) GetDc added in v1.0.3

func (c *Cache) GetDc(logger utils.Logger, domain string) (string, error)

GetDc returns a cached or newly discovered domain controller for a given domain. If a valid entry exists in the cache, it is returned. Otherwise, GetDc attempts to discover a new DC and caches it. If discovery fails but a stale cache entry existed, the stale entry is returned with a debug log.

func (*Cache) GetKdc added in v1.0.3

func (c *Cache) GetKdc(logger utils.Logger, realm string) ([]string, error)

GetKdc returns cached or resolved key distribution center addresses for a given kerberos realm. It first checks the cache for valid entries. If none are found, or they are expired, it performs an SRV lookup to discover key distribution centers and caches the results. If SRV lookup fails but a stale cache entry exists, it falls back to the stale entry.

Jump to

Keyboard shortcuts

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