This commit is contained in:
31
main.go
31
main.go
@@ -2,12 +2,19 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
|
"encoding/json"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
auth "github.com/korylprince/go-ad-auth/v3"
|
auth "github.com/korylprince/go-ad-auth/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type Output struct {
|
||||||
|
Server string
|
||||||
|
AuthSuccess bool
|
||||||
|
Error string
|
||||||
|
}
|
||||||
|
|
||||||
const WSDCCertPem = `
|
const WSDCCertPem = `
|
||||||
-----BEGIN CERTIFICATE-----
|
-----BEGIN CERTIFICATE-----
|
||||||
MIIJZzCCCE+gAwIBAgIKYQTouAAAAAAABzANBgkqhkiG9w0BAQsFADCBpzELMAkG
|
MIIJZzCCCE+gAwIBAgIKYQTouAAAAAAABzANBgkqhkiG9w0BAQsFADCBpzELMAkG
|
||||||
@@ -65,6 +72,8 @@ lS3ZUQcHCLtUbTw=
|
|||||||
`
|
`
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
var output Output
|
||||||
|
|
||||||
// Process command line arguments
|
// Process command line arguments
|
||||||
server := flag.String("server", "ldap.example.com", "LDAP server to bind to")
|
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")
|
baseDN := flag.String("baseDN", "OU=Users,DC=example,DC=com", "Base DN to use when attempting to bind to AD")
|
||||||
@@ -72,6 +81,8 @@ func main() {
|
|||||||
password := flag.String("password", "pass", "Password to use when attempting to bind to AD")
|
password := flag.String("password", "pass", "Password to use when attempting to bind to AD")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
output.Server = *server
|
||||||
|
|
||||||
// Get a copy of the system defined CA's
|
// Get a copy of the system defined CA's
|
||||||
system, err := x509.SystemCertPool()
|
system, err := x509.SystemCertPool()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -97,13 +108,21 @@ func main() {
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
//handle err
|
//handle err
|
||||||
fmt.Println(err)
|
//fmt.Println("Error : %s", err)
|
||||||
|
output.Error = err.Error()
|
||||||
}
|
}
|
||||||
|
|
||||||
if !status {
|
output.AuthSuccess = status
|
||||||
//handle failed authentication
|
|
||||||
fmt.Println(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Println("success")
|
/*
|
||||||
|
if !status {
|
||||||
|
//handle failed authentication
|
||||||
|
fmt.Println("Authentication failed")
|
||||||
|
} else {
|
||||||
|
fmt.Println("success")
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
b, _ := json.Marshal(output)
|
||||||
|
fmt.Println(string(b))
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user