### Start Method Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Initializes goroutines for reading replies and processing messages. Avoid calling this alongside Dial or DialURL to prevent race conditions. ```go func (l *Conn) Start() ``` -------------------------------- ### User Authentication Example Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Demonstrates how a typical application can verify a login attempt. Refer to https://github.com/go-ldap/ldap/issues/93 for issues revolving around unauthenticated binds, with zero length passwords. ```go package main import ( "fmt" "log" "github.com/go-ldap/ldap/v3" ) func main() { // Connect to your LDAP server l, err := ldap.DialURL("ldap://localhost:389") if err != nil { log.Fatalf("Failed to connect to LDAP server: %v", err) } defer l.Close() // Bind with a user and password username := "cn=admin,dc=example,dc=com" password := "your_password" err = l.Bind(username, password) if err != nil { log.Fatalf("Failed to bind to LDAP server: %v", err) } // Search for a user (example) searchRequest := ldap.NewSearchRequest( "dc=example,dc=com", // Base DN ldap.ScopeWholeSubtree, ldap.DerefAlways, 0, 0, false, "(uid=testuser)", // Filter []string{"cn", "sn", "givenName", "mail"}, // Attributes nil, ) searchResult, err := l.Search(searchRequest) if err != nil { log.Fatalf("Failed to search LDAP: %v", err) } fmt.Printf("Found %d entries:\n", len(searchResult.Entries)) for _, entry := range searchResult.Entries { fmt.Printf(" DN: %s\n", entry.DN) for _, attr := range entry.Attributes { fmt.Printf(" %s: %v\n", attr.Name, attr.Values) } } } ``` -------------------------------- ### Get ServerSideSorting Control Type Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 GetControlType returns the OID for the ControlServerSideSorting, identifying it as the server-side sorting control. ```go func (c *ControlServerSideSorting) GetControlType() string ``` -------------------------------- ### StartTLS Method Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Initiates a TLS session and creates a new TLS client. ```go func (l *Conn) StartTLS(config *tls.Config) error ``` -------------------------------- ### Get Paging Control Type Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 GetControlType returns the OID for the ControlPaging, identifying it as the standard LDAP paging control. ```go func (c *ControlPaging) GetControlType() string ``` -------------------------------- ### Get Microsoft ServerLinkTTL Control Type Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 GetControlType returns the OID for the ControlMicrosoftServerLinkTTL, identifying it as a specific type of LDAP control. ```go func (c *ControlMicrosoftServerLinkTTL) GetControlType() string ``` -------------------------------- ### Get Microsoft SDFlags Control Type Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 GetControlType returns the OID string for the ControlMicrosoftSDFlags. This identifies the type of control being used. ```go func (c *ControlMicrosoftSDFlags) GetControlType() string ``` -------------------------------- ### Initialize NewSimpleBindRequest Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Returns a new bind request instance. ```go func NewSimpleBindRequest(username string, password string, controls []Control) *SimpleBindRequest ``` -------------------------------- ### Get Microsoft ShowDeleted Control Type Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 GetControlType returns the OID for the ControlMicrosoftShowDeleted, identifying its specific function within LDAP operations. ```go func (c *ControlMicrosoftShowDeleted) GetControlType() string ``` -------------------------------- ### NewClientWithKeytab Function - gssapi Package Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3/gssapi Initialize a GSSAPI client with credentials from a keytab file. The realm can be omitted to use the default from configuration. ```go func NewClientWithKeytab(username, realm, keytabPath, krb5confPath string, settings ...func(*client.Settings)) (*Client, error) ``` -------------------------------- ### StartTLS Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Initiates a TLS session. ```APIDOC ## StartTLS ### Description Sends the command to start a TLS session and creates a new TLS Client. ### Parameters #### Arguments - **config** (*tls.Config) - Required - TLS configuration ### Response - **error** - Returns error if TLS handshake fails ``` -------------------------------- ### InitSecContextWithOptions Method - gssapi Client Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3/gssapi Initiate the GSSAPI security context establishment with a target service, allowing for optional GSSAPI security options. ```go func (client *Client) InitSecContextWithOptions(target string, input []byte, APOptions []int) ([]byte, bool, error) ``` -------------------------------- ### Syncrepl Method Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Implements the LDAP Sync Replication engine for consumer-side persistent searches. ```go func (l *Conn) Syncrepl( ctx context.Context, searchRequest *SearchRequest, bufferSize int, mode ControlSyncRequestMode, cookie []byte, reloadHint bool, ) Response ``` -------------------------------- ### Create New EntryAttribute Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Initializes a new EntryAttribute instance. ```go func NewEntryAttribute(name string, values []string) *EntryAttribute ``` -------------------------------- ### Implement ControlSyncDone Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Sync Done control implementation as per RFC 4533. ```go type ControlSyncDone struct { Criticality bool Cookie []byte RefreshDeletes bool } ``` ```go func NewControlSyncDone(pkt *ber.Packet) (*ControlSyncDone, error) ``` ```go func (c *ControlSyncDone) Encode() *ber.Packet ``` ```go func (c *ControlSyncDone) GetControlType() string ``` ```go func (c *ControlSyncDone) String() string ``` -------------------------------- ### Print Method for Entry Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Outputs a human-readable description of an Entry. ```go func (e *Entry) Print() ``` -------------------------------- ### Create New ExtendedRequest Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Initializes a new ExtendedRequest. ```go func NewExtendedRequest(name string, value *ber.Packet) *ExtendedRequest ``` -------------------------------- ### Implement ControlString Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Generic control implementation for simple string-based controls. ```go type ControlString struct { ControlType string Criticality bool ControlValue string } ``` ```go func NewControlString(controlType string, criticality bool, controlValue string) *ControlString ``` ```go func (c *ControlString) Encode() *ber.Packet ``` ```go func (c *ControlString) GetControlType() string ``` ```go func (c *ControlString) String() string ``` -------------------------------- ### Client Initialization Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3/gssapi Provides methods for creating a GSS-API client using different authentication mechanisms. ```APIDOC ## Client Initialization ### Description These functions are used to create and initialize a new GSS-API client. ### NewClientFromCCache #### Description NewClientFromCCache creates a new client from a populated client cache. #### Method N/A (Constructor) #### Endpoint N/A #### Parameters ##### Path Parameters N/A ##### Query Parameters N/A ##### Request Body N/A ### NewClientWithKeytab #### Description NewClientWithKeytab creates a new client from a keytab credential. Set the realm to empty string to use the default realm from config. #### Method N/A (Constructor) #### Endpoint N/A #### Parameters ##### Path Parameters N/A ##### Query Parameters N/A ##### Request Body N/A ### NewClientWithPassword #### Description NewClientWithPassword creates a new client from a password credential. Set the realm to empty string to use the default realm from config. #### Method N/A (Constructor) #### Endpoint N/A #### Parameters ##### Path Parameters N/A ##### Query Parameters N/A ##### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### InitSecContext Method - gssapi Client Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3/gssapi Initiate the GSSAPI security context establishment with a target service. This method is used for the initial steps of the handshake. ```go func (client *Client) InitSecContext(target string, input []byte) ([]byte, bool, error) ``` -------------------------------- ### SimpleBind Method Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Performs a simple bind operation using the provided request parameters. ```go func (l *Conn) SimpleBind(simpleBindRequest *SimpleBindRequest) (*SimpleBindResult, error) ``` -------------------------------- ### PrettyPrint EntryAttribute Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Outputs a human-readable description with indentation. ```go func (e *EntryAttribute) PrettyPrint(indent int) ``` -------------------------------- ### PrettyPrint Method for Entry Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Outputs a human-readable description of an Entry, with specified indentation for formatting. ```go func (e *Entry) PrettyPrint(indent int) ``` -------------------------------- ### WhoAmI Method Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Retrieves the authorization identity from the server, optionally accepting controls. ```go func (l *Conn) WhoAmI(controls []Control) (*WhoAmIResult, error) ``` -------------------------------- ### SearchWithPaging Method Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Executes LDAP queries with paging support. Results are buffered and returned atomically. ```go func (l *Conn) SearchWithPaging(searchRequest *SearchRequest, pagingSize uint32) (*SearchResult, error) ``` -------------------------------- ### NewClientFromCCache Function - gssapi Package Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3/gssapi Create a new GSSAPI client using credentials from a ccache file. Configuration can be customized using optional settings functions. ```go func NewClientFromCCache(ccachePath, krb5confPath string, settings ...func(*client.Settings)) (*Client, error) ``` -------------------------------- ### DialContext Configuration Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Parameters and options for dialing LDAP URLs. ```go type DialContext struct { // contains filtered or unexported fields } ``` ```go type DialOpt func(*DialContext) ``` ```go func DialWithDialer(d *net.Dialer) DialOpt ``` ```go func DialWithTLSConfig(tc *tls.Config) DialOpt ``` -------------------------------- ### TLSConnectionState Method Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Retrieves the current TLS connection state. Returns zero values if StartTLS was not successful. ```go func (l *Conn) TLSConnectionState() (state tls.ConnectionState, ok bool) ``` -------------------------------- ### NewSimpleBindRequest Constructor Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Constructor function to initialize a new SimpleBindRequest. ```APIDOC ## NewSimpleBindRequest ### Description Returns a new instance of a SimpleBindRequest. ### Parameters - **username** (string) - Required - The bind username. - **password** (string) - Required - The bind password. - **controls** ([]Control) - Required - The controls to include in the request. ``` -------------------------------- ### NewClientWithPassword Function - gssapi Package Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3/gssapi Instantiate a GSSAPI client using a username and password. The realm can be omitted to use the default from configuration. ```go func NewClientWithPassword(username, realm, password string, krb5confPath string, settings ...func(*client.Settings)) (*Client, error) ``` -------------------------------- ### DN Comparison Methods Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Methods for comparing DNs, including ancestor checks and equality checks with optional case-folding. ```go func (d *DN) AncestorOf(other *DN) bool ``` ```go func (d *DN) AncestorOfFold(other *DN) bool ``` ```go func (d *DN) Equal(other *DN) bool ``` ```go func (d *DN) EqualFold(other *DN) bool ``` ```go func (d *DN) String() string ``` -------------------------------- ### Create NewPostalAddress Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Creates a new PostalAddress by copying non-empty lines from the provided slice of strings. ```go func NewPostalAddress(lines []string) (*PostalAddress, error) ``` -------------------------------- ### SearchRequest Structure and Constructor Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Defines the structure for an LDAP search request and the constructor to initialize it. ```go type SearchRequest struct { BaseDN string Scope int DerefAliases int SizeLimit int TimeLimit int TypesOnly bool Filter string Attributes []string Controls []Control // EnforceSizeLimit will hard limit the maximum number of entries parsed, in case the directory // server returns more results than requested. This setting is disabled by default and does not // work in async search requests. EnforceSizeLimit bool } ``` ```go func NewSearchRequest( BaseDN string, Scope, DerefAliases, SizeLimit, TimeLimit int, TypesOnly bool, Filter string, Attributes []string, Controls []Control, ) *SearchRequest ``` -------------------------------- ### LDAP Scope Map Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Provides human-readable descriptions for LDAP scope integer constants. ```go var ScopeMap = map[int]string{ ScopeBaseObject: "Base Object", ScopeSingleLevel: "Single Level", ScopeWholeSubtree: "Whole Subtree", ScopeChildren: "Children", } ``` -------------------------------- ### Define SimpleBindRequest structure Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Represents a username/password bind operation. ```go type SimpleBindRequest struct { // Username is the name of the Directory object that the client wishes to bind as Username string // Password is the credentials to bind with Password string // Controls are optional controls to send with the bind request Controls []Control // AllowEmptyPassword sets whether the client allows binding with an empty password // (normally used for unauthenticated bind). AllowEmptyPassword bool } ``` -------------------------------- ### ControlSyncDone Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Implements the Sync Done Control as described in RFC 4533. ```APIDOC ## ControlSyncDone ### Description Represents the Sync Done Control used in LDAP synchronization. ### Methods - **NewControlSyncDone(pkt *ber.Packet)**: Creates a new control from a BER packet. - **Encode() *ber.Packet**: Encodes the control into a BER packet. - **GetControlType() string**: Returns the OID. - **String() string**: Returns a human-readable description. ``` -------------------------------- ### NewEntry Function Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Creates and returns an Entry object. It takes a distinguished name and a map of attributes. The attributes are processed in alphabetical order of keys to ensure consistent output. ```go func NewEntry(dn string, attributes map[string][]string) *Entry ``` -------------------------------- ### Define SimpleBindResult structure Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Contains the response from the server after a bind operation. ```go type SimpleBindResult struct { Controls []Control } ``` -------------------------------- ### Dial LDAP Connection Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Methods for establishing an LDAP connection. ```go func Dial(network, addr string) (*Conn, error) ``` ```go func DialTLS(network, addr string, config *tls.Config) (*Conn, error) ``` ```go func DialURL(addr string, opts ...DialOpt) (*Conn, error) ``` ```go func NewConn(conn net.Conn, isTLS bool) *Conn ``` -------------------------------- ### Print EntryAttribute Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Outputs a human-readable description of the attribute. ```go func (e *EntryAttribute) Print() ``` -------------------------------- ### ControlDirSync Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Implementation of the DirSync control for Microsoft Active Directory. ```APIDOC ## ControlDirSync ### Description Implements the DirSync control as described in Microsoft documentation. ### Fields - **Criticality** (bool) - Indicates if the control is critical. - **Flags** (int64) - DirSync flags. - **MaxAttrCount** (int64) - Maximum attribute count. - **Cookie** ([]byte) - Sync cookie. ### Methods - **NewRequestControlDirSync(flags, maxAttrCount, cookie)** - Returns a new request control. - **NewResponseControlDirSync(value)** - Returns a new response control from a BER packet. - **SetCookie(cookie)** - Updates the cookie in the control. ``` -------------------------------- ### ControlVChuPasswordWarning Implementation Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Implements the password warning control as defined in the vchu draft. ```go type ControlVChuPasswordWarning struct { // Expire indicates the time in seconds until the password expires Expire int64 } ``` ```go func (c *ControlVChuPasswordWarning) Encode() *ber.Packet ``` ```go func (c *ControlVChuPasswordWarning) GetControlType() string ``` ```go func (c *ControlVChuPasswordWarning) String() string ``` -------------------------------- ### Conn Struct Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Represents an LDAP Connection. ```go type Conn struct { Debug debugging // contains filtered or unexported fields } ``` -------------------------------- ### Client Security Context Establishment Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3/gssapi Methods for initiating and managing the GSS-API security context establishment. ```APIDOC ## Client Security Context Establishment ### Description These methods are used to initiate and manage the establishment of a GSS-API security context. ### InitSecContext #### Description InitSecContext initiates the establishment of a security context for GSS-API between the client and server. See RFC 4752 section 3.1. #### Method N/A (Method) #### Endpoint N/A #### Parameters ##### Path Parameters N/A ##### Query Parameters N/A ##### Request Body N/A ### InitSecContextWithOptions #### Description InitSecContextWithOptions initiates the establishment of a security context for GSS-API between the client and server. See RFC 4752 section 3.1. #### Method N/A (Method) #### Endpoint N/A #### Parameters ##### Path Parameters N/A ##### Query Parameters N/A ##### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### Create Microsoft ServerLinkTTL Control Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Use NewControlMicrosoftServerLinkTTL to instantiate a ControlMicrosoftServerLinkTTL control. This control is related to the lifetime of server links in Active Directory. ```go func NewControlMicrosoftServerLinkTTL() *ControlMicrosoftServerLinkTTL ``` -------------------------------- ### SearchWithPaging Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Executes LDAP queries with paging support. ```APIDOC ## SearchWithPaging ### Description Accepts a search request and desired page size to execute LDAP queries. Results are buffered and returned atomically. ### Parameters #### Arguments - **searchRequest** (*SearchRequest) - Required - The LDAP search request - **pagingSize** (uint32) - Required - The number of entries per page ### Response - **SearchResult** - The aggregated search result - **error** - Error if the operation fails ``` -------------------------------- ### ControlString Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 A generic implementation of the Control interface for simple string-based controls. ```APIDOC ## ControlString ### Description Implements the Control interface for simple controls using a string value. ### Methods - **NewControlString(controlType string, criticality bool, controlValue string)**: Returns a new generic control. - **Encode() *ber.Packet**: Returns the BER packet representation. - **GetControlType() string**: Returns the OID. - **String() string**: Returns a human-readable description. ``` -------------------------------- ### SearchResult Structure and Methods Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Holds search results and provides methods for printing them. ```go type SearchResult struct { // Entries are the returned entries Entries []*Entry // Referrals are the returned referrals Referrals []string // Controls are the returned controls Controls []Control } ``` ```go func (s *SearchResult) PrettyPrint(indent int) ``` ```go func (s *SearchResult) Print() ``` -------------------------------- ### SimpleBind Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Performs a simple bind operation. ```APIDOC ## SimpleBind ### Description Performs the simple bind operation defined in the given request. ### Parameters #### Arguments - **simpleBindRequest** (*SimpleBindRequest) - Required - The bind request details ### Response - **SimpleBindResult** - The result of the bind operation - **error** - Error if the bind fails ``` -------------------------------- ### Create Paging Control Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Use NewControlPaging to create a paging control with a specified page size. This is used for implementing manual pagination in LDAP searches. ```go func NewControlPaging(pagingSize uint32) *ControlPaging ``` -------------------------------- ### LDAP Client Interface Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Defines the interface for interacting with an LDAP server. ```go type Client interface { Start() StartTLS(*tls.Config) error Close() error GetLastError() error IsClosing() bool SetTimeout(time.Duration) TLSConnectionState() (tls.ConnectionState, bool) Bind(username, password string) error UnauthenticatedBind(username string) error SimpleBind(*SimpleBindRequest) (*SimpleBindResult, error) ExternalBind() error NTLMUnauthenticatedBind(domain, username string) error Unbind() error Add(*AddRequest) error Del(*DelRequest) error Modify(*ModifyRequest) error ModifyDN(*ModifyDNRequest) error ModifyWithResult(*ModifyRequest) (*ModifyResult, error) Extended(*ExtendedRequest) (*ExtendedResponse, error) Compare(dn, attribute, value string) (bool, error) PasswordModify(*PasswordModifyRequest) (*PasswordModifyResult, error) Search(*SearchRequest) (*SearchResult, error) SearchAsync(ctx context.Context, searchRequest *SearchRequest, bufferSize int) Response SearchWithPaging(searchRequest *SearchRequest, pagingSize uint32) (*SearchResult, error) DirSync(searchRequest *SearchRequest, flags, maxAttrCount int64, cookie []byte) (*SearchResult, error) DirSyncAsync(ctx context.Context, searchRequest *SearchRequest, bufferSize int, flags, maxAttrCount int64, cookie []byte) Response Syncrepl(ctx context.Context, searchRequest *SearchRequest, bufferSize int, mode ControlSyncRequestMode, cookie []byte, reloadHint bool) Response } ``` -------------------------------- ### ControlSyncState String Representation Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Returns a human-readable description of the ControlSyncState. ```go func (c *ControlSyncState) String() string ``` -------------------------------- ### SearchSingleResult Structure and Methods Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Holds a single entry response to a search request with printing methods. ```go type SearchSingleResult struct { // Entry is the returned entry Entry *Entry // Referral is the returned referral Referral string // Controls are the returned controls Controls []Control // Error is set when the search request was failed Error error } ``` ```go func (s *SearchSingleResult) PrettyPrint(indent int) ``` ```go func (s *SearchSingleResult) Print() ``` -------------------------------- ### Create ServerSideSorting Control with Sort Keys Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 NewControlServerSideSortingWithSortKeys constructs a ControlServerSideSorting control directly from a slice of SortKey objects. This is used when initiating a search with sorting criteria. ```go func NewControlServerSideSortingWithSortKeys(sortKeys []*SortKey) *ControlServerSideSorting ``` -------------------------------- ### RelativeDN Methods Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Methods for comparing and string representation of RelativeDN objects. ```go func (r *RelativeDN) Equal(other *RelativeDN) bool ``` ```go func (r *RelativeDN) EqualFold(other *RelativeDN) bool ``` ```go func (r *RelativeDN) String() string ``` -------------------------------- ### SimpleBindRequest Structure Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Defines the structure for a simple username/password bind request. ```APIDOC ## SimpleBindRequest ### Description Represents a username/password bind operation for LDAP authentication. ### Request Body - **Username** (string) - Required - The name of the Directory object that the client wishes to bind as. - **Password** (string) - Required - The credentials to bind with. - **Controls** ([]Control) - Optional - Optional controls to send with the bind request. - **AllowEmptyPassword** (bool) - Optional - Sets whether the client allows binding with an empty password. ``` -------------------------------- ### ControlSyncState Constants Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Defines the possible states for ControlSyncState. ```go type ControlSyncStateState int64 const ( SyncStatePresent ControlSyncStateState = 0 SyncStateAdd ControlSyncStateState = 1 SyncStateModify ControlSyncStateState = 2 SyncStateDelete ControlSyncStateState = 3 ) ``` -------------------------------- ### Response Interface Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Interface for retrieving data from an LDAP server response. ```go type Response interface { Entry() *Entry Referral() string Controls() []Control Err() error Next() bool } ``` -------------------------------- ### Define NTLMBindResult struct Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Contains the response from the server for an NTLM bind. ```go type NTLMBindResult struct { Controls []Control } ``` -------------------------------- ### String Representation of ServerSideSorting Control Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 The String method for ControlServerSideSorting provides a human-readable description of the control, including the sort keys. ```go func (c *ControlServerSideSorting) String() string ``` -------------------------------- ### SearchAsync Method Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Performs an asynchronous search request. Results are returned until an error occurs or the context is cancelled. ```go func (l *Conn) SearchAsync( ctx context.Context, searchRequest *SearchRequest, bufferSize int) Response ``` -------------------------------- ### PostalAddress Methods Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Methods for comparing, escaping, and retrieving lines from a PostalAddress object. ```go func (p *PostalAddress) Equal(other *PostalAddress) bool ``` ```go func (p *PostalAddress) Escape() string ``` ```go func (p *PostalAddress) Lines() []string ``` ```go func (p *PostalAddress) String() string ``` -------------------------------- ### Define ControlTypeMap Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Maps LDAP control types to their human-readable descriptions. ```go ControlTypeMicrosoftPolicyHintsDeprecated: "Policy Hints Deprecated - Microsoft", ControlTypeMicrosoftDirSyncEX: "DirSync EX - Microsoft", ControlTypeMicrosoftUpdateStats: "Update Stats - Microsoft", ControlTypeMicrosoftTreeDeleteEX: "Tree Delete EX - Microsoft", ControlTypeMicrosoftSearchHints: "Search Hints - Microsoft", ControlTypeMicrosoftExpectedEntryCount: "Expected Entry Count - Microsoft", ControlTypeMicrosoftPolicyHints: "Policy Hints - Microsoft", ControlTypeMicrosoftSetOwner: "Set Owner - Microsoft", ControlTypeMicrosoftBypassQuota: "Bypass Quota - Microsoft", ControlTypeMicrosoftServerLinkTTL: "Return TTL-DNs for link values with associated expiry times - Microsoft", ControlTypeMicrosoftSetCorrelationID: "Set Correlation ID - Microsoft", ControlTypeMicrosoftThreadTraceOverride: "Thread Trace Override - Microsoft", ControlTypeSyncRequest: "Sync Request", ControlTypeSyncState: "Sync State", ControlTypeSyncDone: "Sync Done", ControlTypeSyncInfo: "Sync Info", } ``` -------------------------------- ### String Representation of Microsoft ServerLinkTTL Control Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 The String method for ControlMicrosoftServerLinkTTL provides a human-readable description of the control. ```go func (c *ControlMicrosoftServerLinkTTL) String() string ``` -------------------------------- ### Implement ControlSubtreeDelete Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Subtree delete control implementation for LDAP operations. ```go type ControlSubtreeDelete struct{} ``` ```go func NewControlSubtreeDelete() *ControlSubtreeDelete ``` ```go func (c *ControlSubtreeDelete) Encode() *ber.Packet ``` ```go func (c *ControlSubtreeDelete) GetControlType() string ``` ```go func (c *ControlSubtreeDelete) String() string ``` -------------------------------- ### Connection Establishment Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Functions for establishing a connection to an LDAP server using various methods. ```APIDOC ## Connection Establishment ### Description Functions for establishing a connection to an LDAP server using various methods. ### Functions #### Dial - **Method**: `func Dial(network, addr string) (*Conn, error)` - **Description**: Connects to the given address on the given network using net.Dial and then returns a new Conn for the connection. Deprecated: Use DialURL instead. #### DialTLS - **Method**: `func DialTLS(network, addr string, config *tls.Config) (*Conn, error)` - **Description**: Connects to the given address on the given network using tls.Dial and then returns a new Conn for the connection. Deprecated: Use DialURL instead. #### DialURL - **Method**: `func DialURL(addr string, opts ...DialOpt) (*Conn, error)` - **Description**: Connects to the given ldap URL. The following schemas are supported: ldap://, ldaps://, ldapi://, and cldap:// (RFC1798, deprecated but used by Active Directory). On success a new Conn for the connection is returned. #### NewConn - **Method**: `func NewConn(conn net.Conn, isTLS bool) *Conn` - **Description**: Returns a new Conn using conn for network I/O. ``` -------------------------------- ### String Representation of Microsoft SDFlags Control Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 The String method for ControlMicrosoftSDFlags provides a human-readable description of the control. ```go func (c *ControlMicrosoftSDFlags) String() string ``` -------------------------------- ### Define Matching Rule Assertion Map Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 A map defining string representations for matching rule assertion types. ```go var MatchingRuleAssertionMap = map[uint64]string{ MatchingRuleAssertionMatchingRule: "Matching Rule Assertion Matching Rule", MatchingRuleAssertionType: "Matching Rule Assertion Type", MatchingRuleAssertionMatchValue: "Matching Rule Assertion Match Value", MatchingRuleAssertionDNAttributes: "Matching Rule Assertion DN Attributes", } ``` -------------------------------- ### Matching Rule Assertion Types Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 A mapping of matching rule assertion types to their descriptions. ```APIDOC ## Matching Rule Assertion Types ### Description Provides string descriptions for different types of matching rule assertions. ### Parameters None ### Request Example None ### Response #### Success Response (200) - **MatchingRuleAssertionMatchingRule** (string) - "Matching Rule Assertion Matching Rule" - **MatchingRuleAssertionType** (string) - "Matching Rule Assertion Type" - **MatchingRuleAssertionMatchValue** (string) - "Matching Rule Assertion Match Value" - **MatchingRuleAssertionDNAttributes** (string) - "Matching Rule Assertion DN Attributes" #### Response Example ```json { "MatchingRuleAssertionMatchingRule": "Matching Rule Assertion Matching Rule", "MatchingRuleAssertionType": "Matching Rule Assertion Type" } ``` ``` -------------------------------- ### Control Interface Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Defines the interface for LDAP controls to encode and describe themselves. ```go type Control interface { // GetControlType returns the OID GetControlType() string // Encode returns the ber packet representation Encode() *ber.Packet // String returns a human-readable description String() string } ``` -------------------------------- ### Conn.Bind Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Authenticates a user with the LDAP server using a distinguished name and password. ```APIDOC ## POST /Conn.Bind ### Description Authenticates the connection using the provided distinguished name and password. ### Method POST ### Endpoint Conn.Bind(username, password) ### Parameters #### Request Body - **username** (string) - Required - The distinguished name of the user. - **password** (string) - Required - The password for the user. ``` -------------------------------- ### String Representation of Paging Control Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 The String method for ControlPaging provides a human-readable description of the control's current state, including the paging size. ```go func (c *ControlPaging) String() string ``` -------------------------------- ### ReadPacket method Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Returns the packet or an error from a PacketResponse. ```go func (pr *PacketResponse) ReadPacket() (*ber.Packet, error) ``` -------------------------------- ### NewAddRequest Function Signature Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Creates a new AddRequest for a given DN, without any initial attributes. Optionally accepts controls. ```go func NewAddRequest(dn string, controls []Control) *AddRequest ``` -------------------------------- ### Define Filter Maps Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Maps for human-readable descriptions of LDAP filter and substring filter choices. ```go var FilterMap = map[uint64]string{ FilterAnd: "And", FilterOr: "Or", FilterNot: "Not", FilterEqualityMatch: "Equality Match", FilterSubstrings: "Substrings", FilterGreaterOrEqual: "Greater Or Equal", FilterLessOrEqual: "Less Or Equal", FilterPresent: "Present", FilterApproxMatch: "Approx Match", FilterExtensibleMatch: "Extensible Match", } ``` ```go var FilterSubstringsMap = map[uint64]string{ FilterSubstringsInitial: "Substrings Initial", FilterSubstringsAny: "Substrings Any", FilterSubstringsFinal: "Substrings Final", } ``` -------------------------------- ### DN and Entry Utilities Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Utilities for parsing Distinguished Names and managing LDAP entry attributes. ```APIDOC ## ParseDN ### Description Parses a string representation of a Distinguished Name into a DN object. ### Parameters - **str** (string) - Required - The DN string to parse. ## NewEntry ### Description Creates a new LDAP entry object. ### Parameters - **dn** (string) - Required - The DN of the entry. - **attributes** (map[string][]string) - Required - A map of attribute names to their values. ``` -------------------------------- ### CompareRequest Struct Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Represents an LDAP CompareRequest operation. ```go type CompareRequest struct { DN string Attribute string Value string } ``` -------------------------------- ### SimpleBindResult Structure Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Represents the response received from the server after a bind operation. ```APIDOC ## SimpleBindResult ### Description Contains the response from the server following a bind request. ### Response - **Controls** ([]Control) - The controls returned by the server. ``` -------------------------------- ### NewPostalAddress Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 NewPostalAddress creates a new PostalAddress by copying non-empty lines from the provided slice of strings. ```APIDOC ## NewPostalAddress ### Description NewPostalAddress creates a new PostalAddress by copying non-empty lines from the provided slice of strings. ### Method func NewPostalAddress(lines []string) (*PostalAddress, error) ``` -------------------------------- ### Entry Object Methods Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Methods for interacting with LDAP search result entries and retrieving attribute values. ```APIDOC ## Entry Object ### Description Represents a single search result entry and provides methods to access its attributes. ### Methods - **GetAttributeValue(attribute string) string**: Returns the first value for the named attribute. - **GetAttributeValues(attribute string) []string**: Returns all values for the named attribute. - **GetRawAttributeValue(attribute string) []byte**: Returns the first value as a byte slice. - **GetRawAttributeValues(attribute string) [][]byte**: Returns all values as a slice of byte slices. - **GetEqualFoldAttributeValue(attribute string) string**: Returns the first value using case-insensitive comparison. - **PrettyPrint(indent int)**: Outputs a human-readable description with indentation. ``` -------------------------------- ### LDAP Connection Operations Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Methods for performing operations on an LDAP connection. ```go func (l *Conn) Add(addRequest *AddRequest) error ``` ```go func (l *Conn) Bind(username, password string) error ``` ```go func (l *Conn) Close() (err error) ``` ```go func (l *Conn) Compare(dn, attribute, value string) (bool, error) ``` ```go func (l *Conn) Del(delRequest *DelRequest) error ``` ```go func (l *Conn) DigestMD5Bind(digestMD5BindRequest *DigestMD5BindRequest) (*DigestMD5BindResult, error) ``` ```go func (l *Conn) DirSync( searchRequest *SearchRequest, flags int64, maxAttrCount int64, cookie []byte, ) (*SearchResult, error) ``` ```go func (l *Conn) DirSyncAsync( ctx context.Context, searchRequest *SearchRequest, bufferSize int, flags, maxAttrCount int64, cookie []byte, ) Response ``` -------------------------------- ### Define LDAPResultCodeMap Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Maps LDAP result codes to their human-readable descriptions. ```go var LDAPResultCodeMap = map[uint16]string{ LDAPResultSuccess: "Success", LDAPResultOperationsError: "Operations Error", LDAPResultProtocolError: "Protocol Error", LDAPResultTimeLimitExceeded: "Time Limit Exceeded", LDAPResultSizeLimitExceeded: "Size Limit Exceeded", LDAPResultCompareFalse: "Compare False", LDAPResultCompareTrue: "Compare True", LDAPResultAuthMethodNotSupported: "Auth Method Not Supported", LDAPResultStrongAuthRequired: "Strong Auth Required", LDAPResultReferral: "Referral", LDAPResultAdminLimitExceeded: "Admin Limit Exceeded", LDAPResultUnavailableCriticalExtension: "Unavailable Critical Extension", LDAPResultConfidentialityRequired: "Confidentiality Required", LDAPResultSaslBindInProgress: "Sasl Bind In Progress", LDAPResultNoSuchAttribute: "No Such Attribute", LDAPResultUndefinedAttributeType: "Undefined Attribute Type", LDAPResultInappropriateMatching: "Inappropriate Matching", LDAPResultConstraintViolation: "Constraint Violation", LDAPResultAttributeOrValueExists: "Attribute Or Value Exists", LDAPResultInvalidAttributeSyntax: "Invalid Attribute Syntax", LDAPResultNoSuchObject: "No Such Object", LDAPResultAliasProblem: "Alias Problem", LDAPResultInvalidDNSyntax: "Invalid DN Syntax", } ``` -------------------------------- ### NTLMBindResult Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 NTLMBindResult contains the response from the server. ```APIDOC ## NTLMBindResult ### Description NTLMBindResult contains the response from the server. ### Fields - **Controls** ([]Control) - The returned controls. ``` -------------------------------- ### DialContext and Dial Options Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Provides mechanisms for configuring LDAP client connections, including options for custom dialers and TLS configurations. ```APIDOC ## type DialContext ### Description DialContext contains necessary parameters to dial the given ldap URL. ``` ```APIDOC ## type DialOpt ### Description DialOpt configures DialContext. ``` ```APIDOC ## func DialWithDialer ### Description DialWithDialer updates the net.Dialer in DialContext. ### Parameters #### Path Parameters - **d** (*net.Dialer) - Required - The net.Dialer to use for establishing connections. ### Returns - DialOpt - A DialOpt function that configures the DialContext. ``` ```APIDOC ## func DialWithTLSConfig ### Description DialWithTLSConfig updates the tls.Config in DialContext. ### Parameters #### Path Parameters - **tc** (*tls.Config) - Required - The tls.Config to use for secure connections. ### Returns - DialOpt - A DialOpt function that configures the DialContext. ``` -------------------------------- ### LDAP Controls Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Utilities for working with LDAP controls. ```APIDOC ## LDAP Controls ### Description Utilities for working with LDAP controls. ### Functions - **DecodeControl(packet *ber.Packet) (Control, error)**: Decodes an LDAP control from a BER packet. - **FindControl(controls []Control, controlType string) Control**: Finds a specific control within a list of controls. ### Control Types - **ControlBeheraPasswordPolicy**: Represents a password policy control. - **NewControlBeheraPasswordPolicy() *ControlBeheraPasswordPolicy**: Creates a new password policy control. - **Encode() *ber.Packet**: Encodes the control into a BER packet. - **GetControlType() string**: Returns the control type string. - **ControlDirSync**: Represents a DirSync control. - **NewControlDirSync(flags int64, maxAttrCount int64, cookie []byte) *ControlDirSync**: Deprecated. Creates a new DirSync control. - **NewRequestControlDirSync(flags int64, maxAttrCount int64, cookie []byte) *ControlDirSync**: Creates a new DirSync control for requests. - **NewResponseControlDirSync(value *ber.Packet) (*ControlDirSync, error)**: Creates a DirSync control from a BER packet for responses. - **Encode() *ber.Packet**: Encodes the control into a BER packet. - **GetControlType() string**: Returns the control type string. ``` -------------------------------- ### ControlVChuPasswordMustChange Implementation Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Implements the password must change control as defined in the vchu draft. ```go type ControlVChuPasswordMustChange struct { // MustChange indicates if the password is required to be changed MustChange bool } ``` ```go func (c *ControlVChuPasswordMustChange) Encode() *ber.Packet ``` ```go func (c *ControlVChuPasswordMustChange) GetControlType() string ``` ```go func (c *ControlVChuPasswordMustChange) String() string ``` -------------------------------- ### LDAP Entry Unmarshal Method Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Parses an LDAP entry into the provided interface pointer. ```go func (e *Entry) Unmarshal(i interface{}) (err error) ``` -------------------------------- ### ControlMicrosoftServerLinkTTL Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Methods for managing Microsoft Server Link TTL control. ```APIDOC ## ControlMicrosoftServerLinkTTL ### Description Implements the Microsoft Server Link TTL control as defined in MS-ADTS. ### Methods - **NewControlMicrosoftServerLinkTTL()**: Returns a new ControlMicrosoftServerLinkTTL instance. - **Encode()**: Returns the ber.Packet representation. - **GetControlType()**: Returns the OID. - **String()**: Returns a human-readable description. ``` -------------------------------- ### Manage ControlServerSideSortingResult Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Structures and methods for handling server-side sorting results. ```go type ControlServerSideSortingResult struct { Criticality bool Result ControlServerSideSortingCode } ``` ```go func NewControlServerSideSortingResult(pkt *ber.Packet) (*ControlServerSideSortingResult, error) ``` ```go func (c *ControlServerSideSortingResult) Encode() *ber.Packet ``` ```go func (control *ControlServerSideSortingResult) GetControlType() string ``` ```go func (c *ControlServerSideSortingResult) String() string ``` -------------------------------- ### Define NTLMBindRequest struct Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Represents an NTLMSSP bind operation. ```go type NTLMBindRequest struct { // Domain is the AD Domain to authenticate too. If not specified, it will be grabbed from the NTLMSSP Challenge Domain string // Username is the name of the Directory object that the client wishes to bind as Username string // Password is the credentials to bind with Password string // AllowEmptyPassword sets whether the client allows binding with an empty password // (normally used for unauthenticated bind). AllowEmptyPassword bool // Hash is the hex NTLM hash to bind with. Password or hash must be provided Hash string // Controls are optional controls to send with the bind request Controls []Control // Negotiator allows to specify a custom NTLM negotiator. Negotiator NTLMNegotiator } ``` -------------------------------- ### Error Interface Implementation Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Methods for the Error type. ```go func (e *Error) Error() string ``` ```go func (e *Error) Unwrap() error ``` -------------------------------- ### Define SortKey structure Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Defines sorting parameters for LDAP operations. ```go type SortKey struct { Reverse bool AttributeType string MatchingRule string } ``` -------------------------------- ### WhoAmI Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Retrieves the authorization identity. ```APIDOC ## WhoAmI ### Description Returns the authzId the server associates with the current connection. ### Parameters #### Arguments - **controls** ([]Control) - Optional - LDAP controls to include ### Response - **WhoAmIResult** - The identity result - **error** - Error if the request fails ``` -------------------------------- ### ControlPaging Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Methods for managing LDAP Paging control. ```APIDOC ## ControlPaging ### Description Implements the paging control described in RFC 2696. ### Parameters - **PagingSize** (uint32) - Page size for the request. - **Cookie** ([]byte) - Opaque value for tracking the paging cursor. ### Methods - **NewControlPaging(pagingSize uint32)**: Returns a new paging control. - **Encode()**: Returns the ber.Packet representation. - **GetControlType()**: Returns the OID. - **SetCookie(cookie []byte)**: Stores the given cookie in the control. - **String()**: Returns a human-readable description. ``` -------------------------------- ### ControlSyncRequest API Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Methods for creating and managing Sync Request Controls to initiate synchronization. ```APIDOC ## ControlSyncRequest ### Description Represents the Sync Request Control used to initiate synchronization with an LDAP server. ### Methods - **NewControlSyncRequest(mode ControlSyncRequestMode, cookie []byte, reloadHint bool)**: Initializes a new Sync Request. - **Encode()**: Encodes the request into a BER packet. - **GetControlType()**: Returns the OID of the control. ``` -------------------------------- ### ControlMicrosoftSDFlags Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Methods for managing Microsoft SD Flags control. ```APIDOC ## ControlMicrosoftSDFlags ### Description Provides methods to create and manage the Microsoft SD Flags control. ### Methods - **NewControlMicrosoftSDFlags()**: Returns a new ControlMicrosoftSDFlags instance. - **Encode()**: Returns the ber.Packet representation. - **GetControlType()**: Returns the control type string. - **String()**: Returns a human-readable description. ``` -------------------------------- ### Define DirSync Control Flags Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Bitmask flags used to configure DirSync control behavior. ```go const ( // Windows Server 2003 and later: If this flag is not present, all of the values, // up to a server-specified limit, in a multivalued attribute are returned when // any value changes. If this flag is present, only the changed values are // returned, provided the attribute is a forward link value. // Windows 2000: Not supported. DirSyncIncrementalValues int64 = 0x80000000 // Do not return private data in the search results. // Windows Server 2003 and later: This flag can optionally be passed to the DC, // but it has no effect. // Windows 2000: Not supported. DirSyncPublicDataOnly int64 = 0x00002000 // Return parent objects before child objects, otherwise parent // objects would appear later in the replication stream. DirSyncAncestorsFirstOrder int64 = 0x00000800 // Windows Server 2003 operating system and later: If this flag is present, // the client can only view objects and attributes that are otherwise accessible // to the client. If this flag is not present, the server checks if the client // has access rights to read the changes in the NC. // Windows 2000 operating system: Not supported. DirSyncObjectSecurity int64 = 0x00000001 ) ``` -------------------------------- ### DebugBinaryFile Function Signature Source: https://pkg.go.dev/github.com/go-ldap/ldap/v3 Reads and prints LDAP packets from a specified file. Takes the filename as a string argument. ```go func DebugBinaryFile(fileName string) error ```