-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4bc9fc4
commit 6c50813
Showing
1 changed file
with
0 additions
and
125 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,128 +128,3 @@ func BindAndSearch(l *ldap.Conn,ldapconfig LdapConfig,user *User) (*ldap.SearchR | |
return nil, fmt.Errorf("Couldn't fetch search entries") | ||
} | ||
} | ||
|
||
|
||
// package main | ||
// | ||
// import ( | ||
// "fmt" | ||
// "log" | ||
// | ||
// "github.com/go-ldap/ldap/v3" | ||
// ) | ||
// | ||
// const ( | ||
// BindUsername = "[email protected]" | ||
// BindPassword = "password" | ||
// FQDN = "DC.example.com" | ||
// BaseDN = "cn=Configuration,dc=example,dc=com" | ||
// Filter = "(objectClass=*)" | ||
// ) | ||
// | ||
// func main() { | ||
// // TLS Connection | ||
// l, err := ConnectTLS() | ||
// if err != nil { | ||
// log.Fatal(err) | ||
// } | ||
// defer l.Close() | ||
// | ||
// // Non-TLS Connection | ||
// //l, err := Connect() | ||
// //if err != nil { | ||
// // log.Fatal(err) | ||
// //} | ||
// //defer l.Close() | ||
// | ||
// // Anonymous Bind and Search | ||
// result, err := AnonymousBindAndSearch(l) | ||
// if err != nil { | ||
// log.Fatal(err) | ||
// } | ||
// result.Entries[0].Print() | ||
// | ||
// // Normal Bind and Search | ||
// result, err = BindAndSearch(l) | ||
// if err != nil { | ||
// log.Fatal(err) | ||
// } | ||
// result.Entries[0].Print() | ||
// } | ||
// | ||
// // Ldap Connection with TLS | ||
// func ConnectTLS() (*ldap.Conn, error) { | ||
// // You can also use IP instead of FQDN | ||
// l, err := ldap.DialURL(fmt.Sprintf("ldaps://%s:636", FQDN)) | ||
// if err != nil { | ||
// return nil, err | ||
// } | ||
// | ||
// return l, nil | ||
// } | ||
// | ||
// // Ldap Connection without TLS | ||
// func Connect() (*ldap.Conn, error) { | ||
// // You can also use IP instead of FQDN | ||
// l, err := ldap.DialURL(fmt.Sprintf("ldap://%s:389", FQDN)) | ||
// if err != nil { | ||
// return nil, err | ||
// } | ||
// | ||
// return l, nil | ||
// } | ||
// | ||
// // Anonymous Bind and Search | ||
// func AnonymousBindAndSearch(l *ldap.Conn) (*ldap.SearchResult, error) { | ||
// l.UnauthenticatedBind("") | ||
// | ||
// anonReq := ldap.NewSearchRequest( | ||
// "", | ||
// ldap.ScopeBaseObject, // you can also use ldap.ScopeWholeSubtree | ||
// ldap.NeverDerefAliases, | ||
// 0, | ||
// 0, | ||
// false, | ||
// Filter, | ||
// []string{}, | ||
// nil, | ||
// ) | ||
// result, err := l.Search(anonReq) | ||
// if err != nil { | ||
// return nil, fmt.Errorf("Anonymous Bind Search Error: %s", err) | ||
// } | ||
// | ||
// if len(result.Entries) > 0 { | ||
// result.Entries[0].Print() | ||
// return result, nil | ||
// } else { | ||
// return nil, fmt.Errorf("Couldn't fetch anonymous bind search entries") | ||
// } | ||
// } | ||
// | ||
// // Normal Bind and Search | ||
// func BindAndSearch(l *ldap.Conn) (*ldap.SearchResult, error) { | ||
// l.Bind(BindUsername, BindPassword) | ||
// | ||
// searchReq := ldap.NewSearchRequest( | ||
// BaseDN, | ||
// ldap.ScopeBaseObject, // you can also use ldap.ScopeWholeSubtree | ||
// ldap.NeverDerefAliases, | ||
// 0, | ||
// 0, | ||
// false, | ||
// Filter, | ||
// []string{}, | ||
// nil, | ||
// ) | ||
// result, err := l.Search(searchReq) | ||
// if err != nil { | ||
// return nil, fmt.Errorf("Search Error: %s", err) | ||
// } | ||
// | ||
// if len(result.Entries) > 0 { | ||
// return result, nil | ||
// } else { | ||
// return nil, fmt.Errorf("Couldn't fetch search entries") | ||
// } | ||
// } |