github.com/hashicorp/vault/sdk@v0.11.0/helper/ldaputil/ldap.go (about)

     1  // Copyright (c) HashiCorp, Inc.
     2  // SPDX-License-Identifier: MPL-2.0
     3  
     4  package ldaputil
     5  
     6  import (
     7  	"github.com/go-ldap/ldap/v3"
     8  )
     9  
    10  func NewLDAP() LDAP {
    11  	return &ldapIfc{}
    12  }
    13  
    14  // LDAP provides ldap functionality, but through an interface
    15  // rather than statically. This allows faking it for tests.
    16  type LDAP interface {
    17  	DialURL(addr string, opts ...ldap.DialOpt) (Connection, error)
    18  }
    19  
    20  type ldapIfc struct{}
    21  
    22  func (l *ldapIfc) DialURL(addr string, opts ...ldap.DialOpt) (Connection, error) {
    23  	return ldap.DialURL(addr, opts...)
    24  }