models

package
v2.2.19 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2025 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SymbolRedirect           = "➜"
	SymbolRedirectAlt        = "⇝" // ➜ ⇝
	SymbolEmptyString        = "∅"
	SymbolBulletPoint        = "●" // ⁃ • ● ⏺
	SymbolBulletPointPrimary = "◉" // ○ ◌ ◎ ◉ ◇ ◈
	SymbolITB                = "💪" // 💪 🦁 👑 🫅 🥷
	SymbolCertificate        = "🔐" // 🔐 🔏 🖋 🪪 📜 📝
	SymbolPwdLastSet         = `🔏` // 🗓️ 📅 📆 🗒️ 🗓️ 🕗🔏 🕰️🔑 ️📅✳ 🛡

	SymbolResponsiblePerson    = "👤"
	SymbolAccountDisabled      = "💀"
	SymbolPasswordExpired      = "⌛"
	SymbolCertificateFromToday = "🚨"
	SymbolSendLimit            = "⇵"

	SymbolTypeKITStaff    = "👔" // 👔 👷 ⛑️ 🎩 🥼 🦺 💼 🧑‍💼️ 🥇
	SymbolTypeKITGuP      = "🤝" // 🙋🏻 ️🤝 🤲 🙌 🦯 🥈
	SymbolTypeKITStudent  = "📚" // 🎓 📚 🎒 🤓 🥉
	SymbolTypeKITAlumni   = "🎓" // 👴 🧔 🏃 🆓 🛸 🥷
	SymbolTypeKITFunction = "🤖" // 🤖 🤠 🤑 🤡
	SymbolTypeKITGroup    = "👥" // 👥 👨‍👩‍👧‍👦 🫂 👨‍👩‍👦‍
	SymbolTypeKITContact  = "📨" // 💬 📇 📔 🗃️ 📨 🗂️
	SymbolTypeKITUnknown  = "👾" // 🧟 🤷 ❓ 🤔 👽 👾 🕵 🤡

	SymbolPseudonym = "👻" // 🦸 🕴️ 👻 🕵️ ‍🌫️ 🌁️
)

Variables

View Source
var (
	SectigoSMIMEIntermediatesCommonNames = []string{
		`GEANT Personal CA 4`,
		`GEANT Personal ECC CA 4`,
		`GEANT eScience Personal CA 4`,
		`GEANT eScience Personal ECC CA 4`,
		`GEANT Code Signing CA 4`,
	}

	HaricaSMIMEIntermediatesCommonNames = []string{
		`GEANT S/MIME ECC 1`,
		`GEANT S/MIME RSA 1`,
	}
)
View Source
var (
	LDAPFilterShortestPrefix shortestprefix.ShortestPrefixResult
	AvailableLDAPFilterNames []string
	LDAPFilterNamesSorted    []string
)
View Source
var (
	ITBSuffixesNoOE = map[string]bool{
		"CN=SCC-ITB-biju":                                 true,
		"CN=SCC-ITB-gesamt":                               true,
		"CN=SCC-ITB-gesamt-SndTo":                         true,
		"CN=SCC-ITB-gruppenverwalter":                     true,
		"CN=SCC-ITB-Manager":                              true,
		"CN=SCC-ITB-mitAdminKonto":                        true,
		"CN=SCC-ITB-mitAdminKontoPortal-Wissenswertes_ro": true,
		"CN=SCC-ITB-Portal_ro":                            true,
		"CN=SCC-ITB-Portal-Wissenswertes_ro":              true,
		"CN=SCC-ITB-XYZTEST":                              true,
		"CN=SCC-ITB-ZZZ":                                  true,
		"CN=SCC-ITB-ZZZ_KS":                               true,
	}
)
View Source
var (
	// LDAPFilter is a map of named LDAP filter templates
	LDAPFilter = map[string]LDAPFilterTemplate{

		"default": {
			Template: template.Must(template.New("Default").Parse(compactFilter(`
		(|
			(sAMAccountName={{- .Query -}})
			(proxyAddresses=smtp:{{- .Query -}}*)
			(mail={{- .Query -}}*)
			(userPrincipalName={{- .Query -}}*)
			(targetAddress=smtp:{{- .Query -}}*)
			(extensionAttribute9={{- .Query -}}*)
			(givenName={{- .Query -}})
			(sn={{- .Query -}}))
		`))),
			Description:     "The default filter searches names, email addresses, account names and a few associated attributes. Account names and personal names need to be fully specified.",
			DisplayPriority: 100,
		},
		"nonames": {
			Template: template.Must(template.New("NoNames").Parse(compactFilter(`
		(|
			(sAMAccountName={{- .Query -}})
			(proxyAddresses=smtp:{{- .Query -}}*)
			(mail={{- .Query -}}*)
			(userPrincipalName={{- .Query -}}*)
			(targetAddress=smtp:{{- .Query -}}*)
			(extensionAttribute9={{- .Query -}}*)
		)`))),
			Description:     "The same as the default filter, but without searching for personal names.",
			DisplayPriority: 80,
		},
		"extensive": {
			Template: template.Must(template.New("Extensive").Parse(compactFilter(`
		(|
			(sAMAccountName={{- .Query -}})
			(proxyAddresses=smtp:{{- .Query -}}*)
			(mail={{- .Query -}}*)
			(userPrincipalName={{- .Query -}}*)
			(targetAddress=smtp:{{- .Query -}}*)
			(extensionAttribute9={{- .Query -}}*)
			(givenName=*{{- .Query -}}*)
			(sn=*{{- .Query -}}*)
			(displayName=*{{- .Query -}}*)
		)`))),
			Description: "Searches a lot of attributes with wildcards on both sides of the query. This filter is slow and should be used with caution.",
		},
		"email": {
			Template: template.Must(template.New("EMail").Parse(compactFilter(`
		(|
			(proxyAddresses=smtp:{{- .Query -}}*)
			(mail={{- .Query -}}*)
			(targetAddress=smtp:{{- .Query -}}*)
		)`))),
			Description:     "Only searches email addresses.",
			DisplayPriority: 70,
		},
		"phone": {
			Template: template.Must(template.New("Phone").Parse(compactFilter(`
			(telephoneNumber=*{{- .Query -}})
		`))),
			Description: "Only searches phone numbers without extension. This is automatically used if the query looks like an internal phone number. Only finds phone numbers that people have published. Use the internal phone search [2] for better results.",
		},
		"account": {
			Template: template.Must(template.New("PrimaryAccount").Parse(compactFilter(`
		(|
			(sAMAccountName={{- .Query -}})
			(userPrincipalName={{- .Query -}}*))
		`))),
			Description: "Only searches account names and user principal names.",
		},
		"distinguishedName": {
			Template: template.Must(template.New("DistinguishedName").Parse(compactFilter(`
			(distinguishedName={{- .Query -}})
		`))),
			Description: "Searches the (full) distinguished name of an object. This is useful for finding a specific object. Only returns no or exactly one result.",
		},
		"itb": {
			Template: template.Must(template.New("DistinguishedName").Parse(compactFilter(`
			(CN=SCC-ITB-{{- .Query -}}*)
		`))),
			Description:     "Looks for ITB account for specific OUs. Use only the OU name as query. Append a wildcard to the search (search »foo« will find »SCC-ITB-FOO« as well as »SCC-ITB-FOOBAR«).",
			DisplayPriority: 55,
		},
		"itbexact": {
			Template: template.Must(template.New("DistinguishedName").Parse(compactFilter(`
			(CN=SCC-ITB-{{- .Query -}})
		`))),
			Description:     "Like itb but only finds exact matches.",
			DisplayPriority: 50,
		},
		"externalRedirect": {
			Template: template.Must(template.New("ExternalRedirect").Parse(compactFilter(`
			(&
				(mail=*)
				(targetAddress=*)
				(!(targetAddress=*.kit.edu)))
		`))),
			Description:     "Searches for external redirect addresses. This filter is slow and should be used with caution. The query is not used.",
			DisplayPriority: 0,
		},
	}
)

Functions

func EmphasizeStringEnds

func EmphasizeStringEnds(s string, length int, style *lipgloss.Style) string

EmphasizeStringEnds returns a string with the first and last ›length‹ characters emphasized by ›style‹.

func GetLDAPFilter

func GetLDAPFilter(name, query string) string

GetLDAPFilter returns a named LDAP filter string with the query already inserted

func IndicateEmptyString

func IndicateEmptyString(s string) string

IndicateEmptyString returns "∅" if the string is empty, otherwise the string itself.

Types

type ExtensionAttributeFive

type ExtensionAttributeFive int
const (
	E5None ExtensionAttributeFive = iota
	E5KITFunction
	E5KITGuP
	E5KITStaff
	E5KITStudent
	E5KITAlumni  // fake state, this is not part of extensionAttribute5
	E5KITGroup   // fake state, this is not part of extensionAttribute5
	E5KITContact // fake state, this is not part of extensionAttribute5
)

func (*ExtensionAttributeFive) MarshalJSON

func (u *ExtensionAttributeFive) MarshalJSON() ([]byte, error)

func (*ExtensionAttributeFive) ToEmoji

func (e *ExtensionAttributeFive) ToEmoji() string

func (*ExtensionAttributeFive) ToString

func (e *ExtensionAttributeFive) ToString() string

type LDAPFilterTemplate

type LDAPFilterTemplate struct {
	Template        *template.Template
	Description     string
	DisplayPriority int
}

type SearchResult

type SearchResult struct {
	CN                         string                 `json:"cn,omitempty"`
	DN                         string                 `json:"distinguishedName,omitempty"`
	Description                string                 `json:"description,omitempty"`
	Department                 string                 `json:"department,omitempty"`
	DisplayName                string                 `json:"displayName,omitempty"`
	GivenName                  string                 `json:"givenName,omitempty"`
	MemberOf                   []string               `json:"memberOf,omitempty"`
	PhysicalDeliveryOfficeName string                 `json:"physicalDeliveryOfficeName,omitempty"`
	SAMAccountName             string                 `json:"sAMAccountName,omitempty"` //nolint:tagliatelle
	SN                         string                 `json:"sn,omitempty"`
	TargetAddress              string                 `json:"targetAddress,omitempty"`
	TelephoneNumber            string                 `json:"telephoneNumber,omitempty"`
	E5                         ExtensionAttributeFive `json:"extensionAttribute5,omitempty"`
	E9                         string                 `json:"extensionAttribute9,omitempty"`
	AccountType                ExtensionAttributeFive `json:"accountType,omitempty"`
	ObjectClass                []string               `json:"objectClass,omitempty"`
	SubmissionContLength       *int                   `json:"submissionContLength,omitempty"`
	UserPrincipalName          string                 `json:"userPrincipalName,omitempty"`
	UserAccountControl         UAC                    `json:"userAccountControl,omitempty"`
	UserCertificate            []UserCertificate      `json:"userCertificate,omitempty"`
	ITB                        []string               `json:"itb,omitempty"`
	IsPseudonym                bool                   `json:"isPseudonym,omitempty"`
	Members                    *[]SearchResult        `json:"members,omitempty"`
	PwdLastSet                 *time.Time             `json:"pwdLastSet,omitempty"` //nolint:tagliatelle
	ProxyAddresses             struct {
		Primary   string   `json:"primary,omitempty"`
		Secondary []string `json:"secondary,omitempty"`
	} `json:"proxyAddresses,omitempty"`
}

func SearchLDAP

func SearchLDAP(conn *ldap.Conn, queryString string, getMembers bool) ([]SearchResult, error)

func (SearchResult) PrettyPrint

func (s SearchResult) PrettyPrint()

func (SearchResult) SingleLineString

func (s SearchResult) SingleLineString() string

type UAC

type UAC int
const (
	UACAccountDisabled UAC = 0x00000002
	UACNormalAccount   UAC = 0x00000200
	UACPasswordExpired UAC = 0x00800000
)

func UACFromLDAPString

func UACFromLDAPString(uac string) UAC

func (UAC) IsAccountDisabled

func (u UAC) IsAccountDisabled() bool

func (UAC) IsNormalAccount

func (u UAC) IsNormalAccount() bool

func (UAC) IsPasswordExpired

func (u UAC) IsPasswordExpired() bool

func (UAC) MarshalJSON

func (u UAC) MarshalJSON() ([]byte, error)

func (UAC) ToEmoji

func (u UAC) ToEmoji() string

func (UAC) ToString

func (u UAC) ToString() string

type UserCertificate

type UserCertificate x509.Certificate

func (*UserCertificate) MarshalJSON

func (u *UserCertificate) MarshalJSON() ([]byte, error)

Source Files

  • SearchResults.go
  • extensionAttributeFive.go
  • ldapFilter.go
  • symbols.go
  • uac.go
  • userCertificate.go

Jump to

Keyboard shortcuts

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