This commit is contained in:
37
main.go
Normal file
37
main.go
Normal file
@@ -0,0 +1,37 @@
|
||||
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")
|
||||
}
|
Reference in New Issue
Block a user