-
-
Save 6LYTH3/cc5d4de5d48d5a02d8df to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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