summaryrefslogtreecommitdiffstats
path: root/examples/search.go
diff options
context:
space:
mode:
authorjuju2013 <catherinedesienne@gmail.com>2014-04-18 15:55:25 +0200
committerjuju2013 <catherinedesienne@gmail.com>2014-04-18 15:55:25 +0200
commit255544907377f696c1046c86f8f327060b1db010 (patch)
tree75b057b798066397e06e554d90877940f0fc2238 /examples/search.go
parentSpruceHealth disappeared :-( (diff)
downloadldap-255544907377f696c1046c86f8f327060b1db010.tar
ldap-255544907377f696c1046c86f8f327060b1db010.tar.gz
ldap-255544907377f696c1046c86f8f327060b1db010.tar.bz2
ldap-255544907377f696c1046c86f8f327060b1db010.tar.lz
ldap-255544907377f696c1046c86f8f327060b1db010.tar.xz
ldap-255544907377f696c1046c86f8f327060b1db010.tar.zst
ldap-255544907377f696c1046c86f8f327060b1db010.zip
Diffstat (limited to 'examples/search.go')
-rw-r--r--examples/search.go27
1 files changed, 17 insertions, 10 deletions
diff --git a/examples/search.go b/examples/search.go
index 77fc214..9618123 100644
--- a/examples/search.go
+++ b/examples/search.go
@@ -12,31 +12,38 @@ import (
)
var (
- LdapServer string = "localhost"
- LdapPort uint16 = 389
- BaseDN string = "dc=enterprise,dc=org"
- Filter string = "(cn=kirkj)"
- Attributes []string = []string{"mail"}
+ ldapServer string = "adserver"
+ ldapPort uint16 = 3268
+ baseDN string = "dc=*,dc=*"
+ filter string = "(&(objectClass=user)(sAMAccountName=*)(memberOf=CN=*,OU=*,DC=*,DC=*))"
+ Attributes []string = []string{"memberof"}
+ user string = "*"
+ passwd string = "*"
)
func main() {
- l, err := ldap.Dial("tcp", fmt.Sprintf("%s:%d", LdapServer, LdapPort))
+ l, err := ldap.Dial("tcp", fmt.Sprintf("%s:%d", ldapServer, ldapPort))
if err != nil {
- log.Fatalf("ERROR: %s\n", err.String())
+ log.Fatalf("ERROR: %s\n", err.Error())
}
defer l.Close()
// l.Debug = true
+ err = l.Bind(user, passwd)
+ if err != nil {
+ log.Printf("ERROR: Cannot bind: %s\n", err.Error())
+ return
+ }
search := ldap.NewSearchRequest(
- BaseDN,
+ baseDN,
ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false,
- Filter,
+ filter,
Attributes,
nil)
sr, err := l.Search(search)
if err != nil {
- log.Fatalf("ERROR: %s\n", err.String())
+ log.Fatalf("ERROR: %s\n", err.Error())
return
}