diff options
author | Samuel Stauffer <samuel@descolada.com> | 2014-03-19 21:57:32 +0100 |
---|---|---|
committer | Samuel Stauffer <samuel@descolada.com> | 2014-03-19 21:57:59 +0100 |
commit | 222854694e922344f18910ce3704115d08ca30cb (patch) | |
tree | 62d54db042f04993a4f89b780f0afb02b9a67e18 | |
parent | connection handling (diff) | |
download | ldap-222854694e922344f18910ce3704115d08ca30cb.tar ldap-222854694e922344f18910ce3704115d08ca30cb.tar.gz ldap-222854694e922344f18910ce3704115d08ca30cb.tar.bz2 ldap-222854694e922344f18910ce3704115d08ca30cb.tar.lz ldap-222854694e922344f18910ce3704115d08ca30cb.tar.xz ldap-222854694e922344f18910ce3704115d08ca30cb.tar.zst ldap-222854694e922344f18910ce3704115d08ca30cb.zip |
Diffstat (limited to '')
-rw-r--r-- | Makefile | 16 | ||||
-rw-r--r-- | README | 2 | ||||
-rw-r--r-- | bind.go | 4 | ||||
-rw-r--r-- | conn.go | 4 | ||||
-rw-r--r-- | control.go | 8 | ||||
-rw-r--r-- | debug.go | 4 | ||||
-rw-r--r-- | examples/modify.go | 4 | ||||
-rw-r--r-- | examples/search.go | 4 | ||||
-rw-r--r-- | examples/searchSSL.go | 4 | ||||
-rw-r--r-- | examples/searchTLS.go | 4 | ||||
-rw-r--r-- | filter.go | 6 | ||||
-rw-r--r-- | filter_test.go | 63 | ||||
-rw-r--r-- | ldap.go | 4 | ||||
-rw-r--r-- | ldap_test.go | 20 | ||||
-rw-r--r-- | modify.go | 4 | ||||
-rw-r--r-- | search.go | 4 |
16 files changed, 71 insertions, 84 deletions
diff --git a/Makefile b/Makefile deleted file mode 100644 index d03d676..0000000 --- a/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright 2009 The Go Authors. All rights reserved. -# Use of this source code is governed by a BSD-style -# license that can be found in the LICENSE file. - -include $(GOROOT)/src/Make.inc - -TARG=github.com/mmitton/ldap -GOFILES=\ - bind.go\ - conn.go\ - control.go\ - filter.go\ - ldap.go\ - search.go\ - -include $(GOROOT)/src/Make.pkg @@ -1,7 +1,7 @@ Basic LDAP v3 functionality for the GO programming language. Required Librarys: - github.com/mmitton/asn1-ber + github.com/SpruceHealth/asn1-ber Working: Connecting to LDAP server @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// File contains Bind functionality package ldap import ( "errors" - "github.com/marcsauter/asn1-ber" + + "github.com/SpruceHealth/asn1-ber" ) func (l *Conn) Bind(username, password string) *Error { @@ -2,16 +2,16 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// This package provides LDAP client functions. package ldap import ( "crypto/tls" "errors" - "github.com/marcsauter/asn1-ber" "log" "net" "sync" + + "github.com/SpruceHealth/asn1-ber" ) const ( @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// This package provides LDAP client functions. package ldap import ( "fmt" - "github.com/marcsauter/asn1-ber" + + "github.com/SpruceHealth/asn1-ber" ) const ( @@ -45,7 +45,7 @@ func (c *ControlString) Encode() *ber.Packet { } func (c *ControlString) String() string { - return fmt.Sprintf("Control Type: %s (%q) Criticality: %s Control Value: %s", ControlTypeMap[c.ControlType], c.ControlType, c.Criticality, c.ControlValue) + return fmt.Sprintf("Control Type: %s (%q) Criticality: %t Control Value: %s", ControlTypeMap[c.ControlType], c.ControlType, c.Criticality, c.ControlValue) } type ControlPaging struct { @@ -76,7 +76,7 @@ func (c *ControlPaging) Encode() *ber.Packet { func (c *ControlPaging) String() string { return fmt.Sprintf( - "Control Type: %s (%q) Criticality: %s PagingSize: %d Cookie: %q", + "Control Type: %s (%q) Criticality: %t PagingSize: %d Cookie: %q", ControlTypeMap[ControlTypePaging], ControlTypePaging, false, @@ -1,9 +1,9 @@ -// File contains debugging functionality package ldap import ( - "github.com/marcsauter/asn1-ber" "log" + + "github.com/SpruceHealth/asn1-ber" ) // debbuging type diff --git a/examples/modify.go b/examples/modify.go index 46799b3..b8f9fe4 100644 --- a/examples/modify.go +++ b/examples/modify.go @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// File contains a modify example package main import ( "errors" "fmt" - "github.com/marcsauter/ldap" "log" + + "github.com/SpruceHealth/ldap" ) var ( diff --git a/examples/search.go b/examples/search.go index 5375551..4d86544 100644 --- a/examples/search.go +++ b/examples/search.go @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// File contains a search example package main import ( "fmt" - "github.com/marcsauter/ldap" "log" + + "github.com/SpruceHealth/ldap" ) var ( diff --git a/examples/searchSSL.go b/examples/searchSSL.go index 84895fc..1022886 100644 --- a/examples/searchSSL.go +++ b/examples/searchSSL.go @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// File contains a search example package main import ( "fmt" - "github.com/marcsauter/ldap" "log" + + "github.com/SpruceHealth/ldap" ) var ( diff --git a/examples/searchTLS.go b/examples/searchTLS.go index c0d4b38..d12b582 100644 --- a/examples/searchTLS.go +++ b/examples/searchTLS.go @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// File contains a search example package main import ( "fmt" - "github.com/marcsauter/ldap" "log" + + "github.com/SpruceHealth/ldap" ) var ( @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// File contains a filter compiler/decompiler package ldap import ( "errors" "fmt" - "github.com/marcsauter/asn1-ber" + + "github.com/SpruceHealth/asn1-ber" ) const ( @@ -245,6 +245,4 @@ func compileFilter(filter string, pos int) (*ber.Packet, int, *Error) { newPos++ return packet, newPos, err } - err = NewError(ErrorFilterCompile, errors.New("Reached end of filter without closing parens")) - return packet, newPos, err } diff --git a/filter_test.go b/filter_test.go index d380b23..4c4ce65 100644 --- a/filter_test.go +++ b/filter_test.go @@ -1,44 +1,45 @@ package ldap import ( - "github.com/marcsauter/asn1-ber" "testing" + + "github.com/SpruceHealth/asn1-ber" ) -type compile_test struct { - filter_str string - filter_type int +type compileTest struct { + filterStr string + filterType int } -var test_filters = []compile_test{ - compile_test{filter_str: "(&(sn=Miller)(givenName=Bob))", filter_type: FilterAnd}, - compile_test{filter_str: "(|(sn=Miller)(givenName=Bob))", filter_type: FilterOr}, - compile_test{filter_str: "(!(sn=Miller))", filter_type: FilterNot}, - compile_test{filter_str: "(sn=Miller)", filter_type: FilterEqualityMatch}, - compile_test{filter_str: "(sn=Mill*)", filter_type: FilterSubstrings}, - compile_test{filter_str: "(sn=*Mill)", filter_type: FilterSubstrings}, - compile_test{filter_str: "(sn=*Mill*)", filter_type: FilterSubstrings}, - compile_test{filter_str: "(sn>=Miller)", filter_type: FilterGreaterOrEqual}, - compile_test{filter_str: "(sn<=Miller)", filter_type: FilterLessOrEqual}, - compile_test{filter_str: "(sn=*)", filter_type: FilterPresent}, - compile_test{filter_str: "(sn~=Miller)", filter_type: FilterApproxMatch}, - // compile_test{ filter_str: "()", filter_type: FilterExtensibleMatch }, +var testFilters = []compileTest{ + compileTest{filterStr: "(&(sn=Miller)(givenName=Bob))", filterType: FilterAnd}, + compileTest{filterStr: "(|(sn=Miller)(givenName=Bob))", filterType: FilterOr}, + compileTest{filterStr: "(!(sn=Miller))", filterType: FilterNot}, + compileTest{filterStr: "(sn=Miller)", filterType: FilterEqualityMatch}, + compileTest{filterStr: "(sn=Mill*)", filterType: FilterSubstrings}, + compileTest{filterStr: "(sn=*Mill)", filterType: FilterSubstrings}, + compileTest{filterStr: "(sn=*Mill*)", filterType: FilterSubstrings}, + compileTest{filterStr: "(sn>=Miller)", filterType: FilterGreaterOrEqual}, + compileTest{filterStr: "(sn<=Miller)", filterType: FilterLessOrEqual}, + compileTest{filterStr: "(sn=*)", filterType: FilterPresent}, + compileTest{filterStr: "(sn~=Miller)", filterType: FilterApproxMatch}, + // compileTest{ filterStr: "()", filterType: FilterExtensibleMatch }, } func TestFilter(t *testing.T) { // Test Compiler and Decompiler - for _, i := range test_filters { - filter, err := CompileFilter(i.filter_str) + for _, i := range testFilters { + filter, err := CompileFilter(i.filterStr) if err != nil { - t.Errorf("Problem compiling %s - %s", err.String()) - } else if filter.Tag != uint8(i.filter_type) { - t.Errorf("%q Expected %q got %q", i.filter_str, FilterMap[uint64(i.filter_type)], FilterMap[uint64(filter.Tag)]) + t.Errorf("Problem compiling %s - %s", i.filterStr, err.String()) + } else if filter.Tag != uint8(i.filterType) { + t.Errorf("%q Expected %q got %q", i.filterStr, FilterMap[uint64(i.filterType)], FilterMap[uint64(filter.Tag)]) } else { o, err := DecompileFilter(filter) if err != nil { - t.Errorf("Problem compiling %s - %s", i, err.String()) - } else if i.filter_str != o { - t.Errorf("%q expected, got %q", i.filter_str, o) + t.Errorf("Problem compiling %s - %s", i.filterStr, err.String()) + } else if i.filterStr != o { + t.Errorf("%q expected, got %q", i.filterStr, o) } } } @@ -46,11 +47,11 @@ func TestFilter(t *testing.T) { func BenchmarkFilterCompile(b *testing.B) { b.StopTimer() - filters := make([]string, len(test_filters)) + filters := make([]string, len(testFilters)) // Test Compiler and Decompiler - for idx, i := range test_filters { - filters[idx] = i.filter_str + for idx, i := range testFilters { + filters[idx] = i.filterStr } max_idx := len(filters) @@ -62,11 +63,11 @@ func BenchmarkFilterCompile(b *testing.B) { func BenchmarkFilterDecompile(b *testing.B) { b.StopTimer() - filters := make([]*ber.Packet, len(test_filters)) + filters := make([]*ber.Packet, len(testFilters)) // Test Compiler and Decompiler - for idx, i := range test_filters { - filters[idx], _ = CompileFilter(i.filter_str) + for idx, i := range testFilters { + filters[idx], _ = CompileFilter(i.filterStr) } max_idx := len(filters) @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// This package provides LDAP client functions. package ldap import ( "errors" "fmt" - "github.com/marcsauter/asn1-ber" "io/ioutil" + + "github.com/SpruceHealth/asn1-ber" ) // LDAP Application Codes diff --git a/ldap_test.go b/ldap_test.go index 00cc7d5..9dd9c71 100644 --- a/ldap_test.go +++ b/ldap_test.go @@ -5,9 +5,9 @@ import ( "testing" ) -var ldap_server string = "ldap.itd.umich.edu" -var ldap_port uint16 = 389 -var base_dn string = "dc=umich,dc=edu" +var ldapServer string = "ldap.itd.umich.edu" +var ldapPort uint16 = 389 +var baseDN string = "dc=umich,dc=edu" var filter []string = []string{ "(cn=cis-fac)", "(&(objectclass=rfc822mailgroup)(cn=*Computer*))", @@ -18,7 +18,7 @@ var attributes []string = []string{ func TestConnect(t *testing.T) { fmt.Printf("TestConnect: starting...\n") - l, err := Dial("tcp", fmt.Sprintf("%s:%d", ldap_server, ldap_port)) + l, err := Dial("tcp", fmt.Sprintf("%s:%d", ldapServer, ldapPort)) if err != nil { t.Errorf(err.String()) return @@ -29,7 +29,7 @@ func TestConnect(t *testing.T) { func TestSearch(t *testing.T) { fmt.Printf("TestSearch: starting...\n") - l, err := Dial("tcp", fmt.Sprintf("%s:%d", ldap_server, ldap_port)) + l, err := Dial("tcp", fmt.Sprintf("%s:%d", ldapServer, ldapPort)) if err != nil { t.Errorf(err.String()) return @@ -37,7 +37,7 @@ func TestSearch(t *testing.T) { defer l.Close() search_request := NewSearchRequest( - base_dn, + baseDN, ScopeWholeSubtree, DerefAlways, 0, 0, false, filter[0], attributes, @@ -54,7 +54,7 @@ func TestSearch(t *testing.T) { func TestSearchWithPaging(t *testing.T) { fmt.Printf("TestSearchWithPaging: starting...\n") - l, err := Dial("tcp", fmt.Sprintf("%s:%d", ldap_server, ldap_port)) + l, err := Dial("tcp", fmt.Sprintf("%s:%d", ldapServer, ldapPort)) if err != nil { t.Errorf(err.String()) return @@ -68,7 +68,7 @@ func TestSearchWithPaging(t *testing.T) { } search_request := NewSearchRequest( - base_dn, + baseDN, ScopeWholeSubtree, DerefAlways, 0, 0, false, filter[1], attributes, @@ -84,7 +84,7 @@ func TestSearchWithPaging(t *testing.T) { func testMultiGoroutineSearch(t *testing.T, l *Conn, results chan *SearchResult, i int) { search_request := NewSearchRequest( - base_dn, + baseDN, ScopeWholeSubtree, DerefAlways, 0, 0, false, filter[i], attributes, @@ -100,7 +100,7 @@ func testMultiGoroutineSearch(t *testing.T, l *Conn, results chan *SearchResult, func TestMultiGoroutineSearch(t *testing.T) { fmt.Printf("TestMultiGoroutineSearch: starting...\n") - l, err := Dial("tcp", fmt.Sprintf("%s:%d", ldap_server, ldap_port)) + l, err := Dial("tcp", fmt.Sprintf("%s:%d", ldapServer, ldapPort)) if err != nil { t.Errorf(err.String()) return @@ -26,12 +26,14 @@ // // AttributeValue ::= OCTET STRING // + package ldap import ( "errors" - "github.com/marcsauter/asn1-ber" "log" + + "github.com/SpruceHealth/asn1-ber" ) const ( @@ -56,13 +56,15 @@ // dnAttributes [4] BOOLEAN DEFAULT FALSE } // // + package ldap import ( "errors" "fmt" - "github.com/marcsauter/asn1-ber" "strings" + + "github.com/SpruceHealth/asn1-ber" ) const ( |