...

Source file src/github.com/go-ldap/ldap/v3/examples_windows_test.go

Documentation: github.com/go-ldap/ldap/v3

     1  //go:build windows
     2  // +build windows
     3  
     4  package ldap
     5  
     6  import (
     7  	"log"
     8  
     9  	"github.com/go-ldap/ldap/v3/gssapi"
    10  )
    11  
    12  // This example demonstrates passwordless bind using the current process' user
    13  // credentials on Windows (SASL GSSAPI mechanism bind with SSPI client).
    14  func ExampleConn_SSPIClient_GSSAPIBind() {
    15  	// Windows only: Create a GSSAPIClient using Windows built-in SSPI lib
    16  	// (secur32.dll).
    17  	// This will use the credentials of the current process' user.
    18  	sspiClient, err := gssapi.NewSSPIClient()
    19  	if err != nil {
    20  		log.Fatal(err)
    21  	}
    22  	defer sspiClient.Close()
    23  
    24  	l, err := DialURL("ldap://ldap.example.com:389")
    25  	if err != nil {
    26  		log.Fatal(err)
    27  	}
    28  	defer l.Close()
    29  
    30  	// Bind using supplied GSSAPIClient implementation
    31  	err = l.GSSAPIBind(sspiClient, "ldap/ldap.example.com", "")
    32  	if err != nil {
    33  		log.Fatal(err)
    34  	}
    35  }
    36  

View as plain text