forked from go-ldap/ldap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexamples_windows_test.go
More file actions
35 lines (29 loc) · 820 Bytes
/
examples_windows_test.go
File metadata and controls
35 lines (29 loc) · 820 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//go:build windows
// +build windows
package ldap
import (
"log"
"github.com/go-ldap/ldap/gssapi"
)
// This example demonstrates passwordless bind using the current process' user
// credentials on Windows (SASL GSSAPI mechanism bind with SSPI client).
func ExampleConn_SSPIClient_GSSAPIBind() {
// Windows only: Create a GSSAPIClient using Windows built-in SSPI lib
// (secur32.dll).
// This will use the credentials of the current process' user.
sspiClient, err := gssapi.NewSSPIClient()
if err != nil {
log.Fatal(err)
}
defer sspiClient.Close()
l, err := DialURL("ldap://ldap.example.com:389")
if err != nil {
log.Fatal(err)
}
defer l.Close()
// Bind using supplied GSSAPIClient implementation
err = l.GSSAPIBind(sspiClient, "ldap/ldap.example.com", "")
if err != nil {
log.Fatal(err)
}
}