summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorHiroki Uchiumi <uchiumi@estrella.co.jp>2019-10-21 22:07:07 +0200
committerNed McClain <nedmcclain@gmail.com>2019-10-21 22:07:07 +0200
commit3b3b69a7e9e3a1fc8b36f6545ae4e0f6e6a63fd2 (patch)
tree17bfbe05c522eb33e679a5fe205bba6b5dd67d75 /examples
parentAdd support for retrieving all user attributes (#5) (diff)
downloadldap-3b3b69a7e9e3a1fc8b36f6545ae4e0f6e6a63fd2.tar
ldap-3b3b69a7e9e3a1fc8b36f6545ae4e0f6e6a63fd2.tar.gz
ldap-3b3b69a7e9e3a1fc8b36f6545ae4e0f6e6a63fd2.tar.bz2
ldap-3b3b69a7e9e3a1fc8b36f6545ae4e0f6e6a63fd2.tar.lz
ldap-3b3b69a7e9e3a1fc8b36f6545ae4e0f6e6a63fd2.tar.xz
ldap-3b3b69a7e9e3a1fc8b36f6545ae4e0f6e6a63fd2.tar.zst
ldap-3b3b69a7e9e3a1fc8b36f6545ae4e0f6e6a63fd2.zip
Diffstat (limited to 'examples')
-rw-r--r--examples/modify.go2
-rw-r--r--examples/proxy.go9
-rw-r--r--examples/server.go7
3 files changed, 12 insertions, 6 deletions
diff --git a/examples/modify.go b/examples/modify.go
index 87d1119..74296b4 100644
--- a/examples/modify.go
+++ b/examples/modify.go
@@ -23,7 +23,7 @@ var (
Filter string = "(cn=kirkj)"
)
-func search(l *ldap.Conn, filter string, attributes []string) (*ldap.Entry, *ldap.Error) {
+func search(l *ldap.Conn, filter string, attributes []string) (*ldap.Entry, error) {
search := ldap.NewSearchRequest(
BaseDN,
ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false,
diff --git a/examples/proxy.go b/examples/proxy.go
index d6b01d0..aebdd10 100644
--- a/examples/proxy.go
+++ b/examples/proxy.go
@@ -1,12 +1,15 @@
+// +build ignore
+
package main
import (
"crypto/sha256"
"fmt"
- "github.com/nmcclain/ldap"
"log"
"net"
"sync"
+
+ "github.com/nmcclain/ldap"
)
type ldapHandler struct {
@@ -61,7 +64,7 @@ func (h ldapHandler) getSession(conn net.Conn) (session, error) {
}
/////////////
-func (h ldapHandler) Bind(bindDN, bindSimplePw string, conn net.Conn) (uint64, error) {
+func (h ldapHandler) Bind(bindDN, bindSimplePw string, conn net.Conn) (ldap.LDAPResultCode, error) {
s, err := h.getSession(conn)
if err != nil {
return ldap.LDAPResultOperationsError, err
@@ -91,7 +94,7 @@ func (h ldapHandler) Search(boundDN string, searchReq ldap.SearchRequest, conn n
//log.Printf("P: Search OK: %s -> num of entries = %d\n", search.Filter, len(sr.Entries))
return ldap.ServerSearchResult{sr.Entries, []string{}, []ldap.Control{}, ldap.LDAPResultSuccess}, nil
}
-func (h ldapHandler) Close(conn net.Conn) error {
+func (h ldapHandler) Close(boundDN string, conn net.Conn) error {
conn.Close() // close connection to the server when then client is closed
h.lock.Lock()
defer h.lock.Unlock()
diff --git a/examples/server.go b/examples/server.go
index 3341991..b8beeeb 100644
--- a/examples/server.go
+++ b/examples/server.go
@@ -1,9 +1,12 @@
+// +build ignore
+
package main
import (
- "github.com/nmcclain/ldap"
"log"
"net"
+
+ "github.com/nmcclain/ldap"
)
/////////////
@@ -27,7 +30,7 @@ func main() {
listen := "localhost:3389"
log.Printf("Starting example LDAP server on %s", listen)
if err := s.ListenAndServe(listen); err != nil {
- log.Fatal("LDAP Server Failed: %s", err.Error())
+ log.Fatalf("LDAP Server Failed: %s", err.Error())
}
}