package main import ( "flag" "fmt" auth "github.com/korylprince/go-ad-auth/v3" ) func main() { // Process command line arguments server := flag.String("server", "ldap.example.com", "LDAP server to bind to") baseDN := flag.String("baseDN", "OU=Users,DC=example,DC=com", "Base DN to use when attempting to bind to AD") username := flag.String("username", "user", "Username to use when attempting to bind to AD") password := flag.String("password", "pass", "Password to use when attempting to bind to AD") config := &auth.Config{ Server: *server, Port: 636, BaseDN: *baseDN, Security: auth.SecurityStartTLS, } status, err := auth.Authenticate(config, *username, *password) if err != nil { //handle err fmt.Println(err) } if !status { //handle failed authentication fmt.Println(err) } fmt.Println("success") }