Skip to content

Instantly share code, notes, and snippets.

@6LYTH3
Forked from sfreiberg/ldap_auth.go
Last active August 29, 2015 14:19
Show Gist options
  • Save 6LYTH3/cc5d4de5d48d5a02d8df to your computer and use it in GitHub Desktop.
Save 6LYTH3/cc5d4de5d48d5a02d8df to your computer and use it in GitHub Desktop.
package main
import (
"github.com/jbcrail/ldap"
"fmt"
)
func main() {
server := "ldap01.example.com:389"
username := "username"
password := "password"
dn := "uid=%s,cn=users,dc=example,dc=com"
ldapConn, err := ldap.Dial("tcp", server)
if err != nil {
fmt.Println(err)
return
}
ldapUser := fmt.Sprintf(dn, username)
err = ldapConn.Bind(ldapUser, password)
if err != nil {
fmt.Println(err)
return
} else {
fmt.Println("Not to get cocky but I think it worked!")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment