Basic LDAP v3 functionality for the GO programming language.

Related tags

Network ldap
Overview

GoDoc Build Status

Basic LDAP v3 functionality for the GO programming language.

Install

For the latest version use:

go get gopkg.in/ldap.v2

Import the latest version with:

import "gopkg.in/ldap.v2"

Required Libraries:

  • gopkg.in/asn1-ber.v1

Features:

  • Connecting to LDAP server (non-TLS, TLS, STARTTLS)
  • Binding to LDAP server
  • Searching for entries
  • Filter Compile / Decompile
  • Paging Search Results
  • Modify Requests / Responses
  • Add Requests / Responses
  • Delete Requests / Responses

Examples:

  • search
  • modify

Contributing:

Bug reports and pull requests are welcome!

Before submitting a pull request, please make sure tests and verification scripts pass:

make all

To set up a pre-push hook to run the tests and verify scripts before pushing:

ln -s ../../.githooks/pre-push .git/hooks/pre-push

The Go gopher was designed by Renee French. (http://reneefrench.blogspot.com/) The design is licensed under the Creative Commons 3.0 Attributions license. Read this article for more details: http://blog.golang.org/gopher

Comments
  • Search returns each result twice?

    Search returns each result twice?

    I seem to be getting each search result twice when querying Active Directory. Haven't dug into debugging yet. Any ideas?

    I have some code like this:

      fmt.Printf("TestSearch: %s -> num of entries = %d\n", search_request.Filter, len(sr.Entries))
      for idx, entry := range sr.Entries {
        fmt.Printf("    %4d - entry: %+v\n", idx, entry)
      }
    

    The output looks like this:

    TestSearch: (objectClass=user) -> num of entries = 579
           0 - entry: &{DN:CN=Kanye West Attributes:[0xc2081b2420 0xc2081b2450]}
           1 - entry: &{DN:CN=Kanye West Attributes:[0xc2081b24b0 0xc2081b24e0]}
           2 - entry: &{DN:CN=Alicia Keys Attributes:[0xc2081b3140 0xc2081b3170]}
           3 - entry: &{DN:CN=Alicia Keys Attributes:[0xc2081b31d0 0xc2081b3200]}
    ...
    
    opened by msabramo 8
  • panic: runtime error: send on closed channel

    panic: runtime error: send on closed channel

    I'm building a web-application that uses an LDAP server for authentication.

    All the server needs to do is login using the LDAP server, no authorizations are made beyond that.

    When I use the library to login once, it works fine, however, on a second try, it will panic.

    A very minimal example that reproduces this problem is:

    package main
    
    import (
        "fmt"
        "github.com/mmitton/ldap"
        "log"
    )
    
    const (
        ADDR   = "WWWW"
        DOMAIN = "XXXX"
        USER   = "YYYY"
        PASS   = "ZZZZ"
    )
    
    func main() {
        fmt.Println("Try 1...")
        doLDAP()
    
        fmt.Println("\nTry 2...")
        doLDAP()
    }
    
    func doLDAP() {
        conn, err := ldap.Dial("tcp", ADDR)
        if err != nil {
            log.Fatal(err)
        }
        defer conn.Close()
    
        fmt.Println("Connected successfully")
    
        err = conn.Bind(DOMAIN+"\\"+USER, PASS)
        if err != nil {
            log.Fatal(err)
        }
    
        fmt.Println("Logged in successfully")
    }
    

    Note that the constants are modified to working values for the LDAP server I am using.

    The output is:

    Try 1...
    Connected successfully
    Logged in successfully
    
    Try 2...
    closeAllChannels
    panic: runtime error: send on closed channel
    
    goroutine 25 [running]:
    runtime.panic(0x5cd8e0, 0x71b19e)
        /tmp/go/src/pkg/runtime/panic.c:279 +0xf5
    github.com/mmitton/ldap.func·003()
        /home/zeal/go/src/github.com/mmitton/ldap/conn.go:299 +0x4c
    created by github.com/mmitton/ldap.(*Conn).sendProcessMessage
        /home/zeal/go/src/github.com/mmitton/ldap/conn.go:299 +0xa0
    
    opened by zealws 3
  • "Message Result chan not found" on the 128th request

    I have a strange error - I have a few hundred queries to run, each only differing in the basedn used. Every time I run the app, the 128th query fails with the same message:

    Sending message 128
    Receiving message 4294967168
    Message Result chan not found (possible Abandon), MessageID: 4294967168
    

    Every message before this succeeds, and I can confirm by seeing

    MessageID: 127, ok: true
    ...
    Sending message 127
    Receiving message 127
    ...
    

    I'm happy to send more information if needed, but does this give you any idea why the 128th query fails?

    opened by rsperl 1
  • Fix erring parsing filter from JXplorer & Apache Directory Studio

    Fix erring parsing filter from JXplorer & Apache Directory Studio

    Fixes an issue decompiling filters sent across from both JXplorer and Apache Directory Studio.

    Unit test included. Example failure:

    --- FAIL: TestDecompileFilter (0.00s) filter_test.go:65: Problem decompiling hwtvYmplY3RjbGFzcw== - LDAP Result Code 202 "": Error decompiling filter filter_test.go:68: hwtvYmplY3RjbGFzcw== Expected (objectclass=*) got ( FAIL

    opened by nwoolls 1
  • Add newline to error messages

    Add newline to error messages

    Otherwise in the output, the lines are all mashed together. E.g.:

    LDAP Result Code 200 "": dial tcp: lookup ldapserver.mycompany.com: no such host2015-01-12T06:40:43.9663425-08:00 POST /users/me/tokens 500 in 12570.002621ms
    
    opened by msabramo 0
  • Invalid filter packets created for basic search

    Invalid filter packets created for basic search

    When I attempt a simple search as follows:

    req := ldap.NewSearchRequest(
        "",
        ldap.ScopeBaseObject,
        ldap.DerefFindingBaseObj,
        0,                          // SizeLimit
        0,                          // TimeLimit
        false,                      // TypesOnly
        "(objectClass=*)",          // Filter
        []string{"rootDomainNamingContext"},
        nil,
    )
    res,err := conn.Search(req)
    

    The server rejects the request. This is because the Go library is apparently generating invalid filter request packets, as detailed in this post on StackExchange: http://stackoverflow.com/q/27022146/13860

    opened by flimzy 0
  • Don't attempt to close nil channels

    Don't attempt to close nil channels

    This avoids a crash when attempting to close a nil Channel. A stack trace of the problem can be seen here: http://pastebin.com/HEb7Duiy

    I have no idea if this is the truly proper solution, or if there's a deeper bug, but this permits my program to run as it should, and return an error code to the caller, rather than crashing.

    opened by flimzy 0
  • Re-format code to be consistent

    Re-format code to be consistent

    gofmt -w *.go

    Reading the source code was making my head hurt, with the mixture of tabs and space indentation, and inconsistent space indentation widths. So I ran it through gofmt.

    opened by flimzy 0
  • Create LICENSE

    Create LICENSE

    This attaches a BSD-like LICENSE, making it usable for people who must pay attention to such things. If this is not the license you intended, or if you intend no such license, please let me know and I'll rescind it. I would request some such license if possible though. Thanks!

    opened by bollenberger 0
  • go get fails for go1.2rc2

    go get fails for go1.2rc2

    github.com/mmitton/asn1-ber

    ../../../Workspaces/go/src/github.com/mmitton/asn1-ber/ber.go:170: undefined: os.Error ../../../Workspaces/go/src/github.com/mmitton/asn1-ber/ber.go:183: undefined: os.Error ../../../Workspaces/go/src/github.com/mmitton/asn1-ber/ber.go:386: undefined: reflect.NewValue

    opened by emicklei 0
  • Resolved issues with conn.go

    Resolved issues with conn.go

    The conn.go was using an outdated net.Dial function. As with the asn1-ber repository, you can safely ignore the last commit as it was only dealing with the goinstall process.

    opened by hsoj 0
  • SCRAM-SHA-1(-PLUS) + SCRAM-SHA-256(-PLUS) + SCRAM-SHA-512(-PLUS) + SCRAM-SHA3-512(-PLUS) supports

    SCRAM-SHA-1(-PLUS) + SCRAM-SHA-256(-PLUS) + SCRAM-SHA-512(-PLUS) + SCRAM-SHA3-512(-PLUS) supports

    Dear @mmitton,

    In first, I wish you a Happy New Year!

    Can you add supports of :

    • SCRAM-SHA-1
    • SCRAM-SHA-1-PLUS
    • SCRAM-SHA-256
    • SCRAM-SHA-256-PLUS
    • SCRAM-SHA-512
    • SCRAM-SHA-512-PLUS
    • SCRAM-SHA3-512
    • SCRAM-SHA3-512-PLUS

    "When using the SASL SCRAM mechanism, the SCRAM-SHA-256-PLUS variant SHOULD be preferred over the SCRAM-SHA-256 variant, and SHA-256 variants [RFC7677] SHOULD be preferred over SHA-1 variants [RFC5802]".

    • SCRAM-SHA-1(-PLUS): -- https://tools.ietf.org/html/rfc5802 -- https://tools.ietf.org/html/rfc6120

    • SCRAM-SHA-256(-PLUS): -- https://tools.ietf.org/html/rfc7677 since 2015-11-02 -- https://tools.ietf.org/html/rfc8600 since 2019-06-21: https://mailarchive.ietf.org/arch/msg/ietf-announce/suJMmeMhuAOmGn_PJYgX5Vm8lNA

    • SCRAM-SHA-512(-PLUS): -- https://tools.ietf.org/html/draft-melnikov-scram-sha-512

    • SCRAM-SHA3-512(-PLUS): -- https://tools.ietf.org/html/draft-melnikov-scram-sha3-512

    https://xmpp.org/extensions/inbox/hash-recommendations.html

    -PLUS variants:

    • RFC5056: On the Use of Channel Bindings to Secure Channels: https://tools.ietf.org/html/rfc5056
    • RFC5929: Channel Bindings for TLS: https://tools.ietf.org/html/rfc5929
    • Channel-Binding Types: https://www.iana.org/assignments/channel-binding-types/channel-binding-types.xhtml
    • RFC 9266: Channel Bindings for TLS 1.3: https://tools.ietf.org/html/rfc9266

    LDAP:

    • RFC5803: Lightweight Directory Access Protocol (LDAP) Schema for Storing Salted: Challenge Response Authentication Mechanism (SCRAM) Secrets: https://tools.ietf.org/html/rfc5803

    HTTP:

    • RFC7804: Salted Challenge Response HTTP Authentication Mechanism: https://tools.ietf.org/html/rfc7804

    2FA:

    • Extensions to Salted Challenge Response (SCRAM) for 2 factor authentication: https://tools.ietf.org/html/draft-melnikov-scram-2fa

    IANA:

    • Simple Authentication and Security Layer (SASL) Mechanisms: https://www.iana.org/assignments/sasl-mechanisms/sasl-mechanisms.xhtml

    Linked to:

    • https://github.com/scram-xmpp/info/issues/1
    opened by Neustradamus 0
  • LDAP SASL bind (SCRAM SHA1) and dealing with binary/BER attribute values

    LDAP SASL bind (SCRAM SHA1) and dealing with binary/BER attribute values

    The bind uses a distinguished name - is it possible to do a SASL bind using ID ([email protected]) instead ? Also, is there a way to add/replace binary/BER attribute values. The API only allows strings.

    opened by gurmeen7b 0
Owner
null
SFTP backed by LDAP and S3-compatible object stores

RainSFTP RainSFTP is an implementaion of the Secure File Transfer Protocol backed by LDAP for authentication and an S3-compatible object store. This m

Megan Ruggiero 5 Nov 8, 2022
Inspired by go-socks5,This package provides full functionality of socks5 protocol.

The protocol described here is designed to provide a framework for client-server applications in both the TCP and UDP domains to conveniently and securely use the services of a network firewall.

Zhangliu 69 Dec 16, 2022
Gogrok is a self hosted, easy to use alternative to ngrok. It uses SSH as a base protocol, using channels and existing functionality to tunnel requests to an endpoint.

gogrok A simple, easy to use ngrok alternative (self hosted!) The server and client can also be easily embedded into your applications, see the 'serve

Tyler Stuyfzand 6 Dec 3, 2022
GRPC - A client-server mockup, using gRPC to expose functionality.

gRPC This is a mockup application that I built to help me visualise and understand the basic concepts of gRPC. In this exchange, the client can use a

Fergal Bittles 0 Jan 4, 2022
Staex GmbH 12 Jun 20, 2022
A cross-platform, decentralized, chat app based on SaltyIM for functionality and GioUI for UI

This project is shifted at https://git.mills.io/saltyim/app Salty UI A cross-platform, decentralized, chat app based on SaltyIM for functionality and

MEARAJ BHAGAD 8 Aug 30, 2022
BGP implemented in the Go Programming Language

GoBGP: BGP implementation in Go GoBGP is an open source BGP implementation designed from scratch for modern environment and implemented in a modern pr

null 3.1k Dec 31, 2022
A simple wrapper around libpcap for the Go programming language

PCAP This is a simple wrapper around libpcap for Go. Originally written by Andreas Krennmair [email protected] and only minorly touched up by Mark Smith

Andreas Krennmair 460 Dec 5, 2022
Diameter stack and Base Protocol (RFC 6733) for the Go programming language

Diameter Base Protocol Package go-diameter is an implementation of the Diameter Base Protocol RFC 6733 and a stack for the Go programming language. St

Alexandre Fiori 214 Dec 28, 2022
SMPP 3.4 Protocol for the Go programming language

SMPP 3.4 This is an implementation of SMPP 3.4 for Go, based on the original smpp34 from Kevin Patel. The API has been refactored to idiomatic Go code

Alexandre Fiori 198 Dec 13, 2022
Go-web-dev - Web Development With Google's Golang Programming Language Code Snippet and Exercises.

Web Development With Google's Golang Programming Language Code Snippet and Exercises This repository contains my code snippets, hands on exercises and

null 2 Jan 16, 2022
The included device-simple example device service demonstrates basic usage of device-sdk-go

device-simple The included device-simple example device service demonstrates basic usage of device-sdk-go. Protocol Driver To make a functional Device

Khalid 0 Oct 9, 2021
A basic port scanner written in go

go-port-scanner A ultra basic port scanner written in go, written for the advanced Go course in Platzi. Compilation Just as any go program go build ma

Eduardo Zepeda 0 Oct 21, 2021
go HTTP client that makes it plain simple to configure TLS, basic auth, retries on specific errors, keep-alive connections, logging, timeouts etc.

goat Goat, is an HTTP client built on top of a standard Go http package, that is extremely easy to configure; no googling required. The idea is simila

VSPAZ 1 Jun 25, 2022
Basic Load Balancer

Load Balancer Work flow based on code snippet Trade-offs: 1. Using etcd as a global variable map. 2. Using etcd to store request references rather tha

Nikhil Vasudev 0 Nov 1, 2021
Basic Got chat program using Ably for networking

Go Terminal Chat Basic Got chat program using Ably for networking. Taken from GopherCon UK 2021: Tom Camp - Creating a basic chat app. Setup Replace t

Stephen Mahon 0 Nov 30, 2021
Basic implementation of WhatsApp message counter by participant.

Whatsapp Group Message Counter This is a learning project to get familiar with some topics related to Golang. make sure to have your exported file on

Jose Luis Rodriguez 1 Dec 23, 2021
Caddy log filter module with a log field filter to extract the user from a basic Authorization HTTP-Header

caddy-basic-auth-filter This packages contains a log field filter to extract the user from a basic Authorization HTTP-Header. Installation xcaddy buil

Steffen Brüheim 2 May 10, 2022