func search(l *ldap.Conn, basedn string, search string, attributes []string) (s *ldap.SearchResult) {
    searchRequest := ldap.NewSearchRequest(
        basedn,
        ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false,
        search,
        attributes,
        nil,
    )
    sr, err := l.Search(searchRequest)
    if err != nil {
        log.Fatal(err)
    }
    if len(sr.Entries) != 1 {
        log.Fatal("User does not exist or too many entries returned")
    }
    return sr
}
This is only good for things you know will return only one result. Be warned.
package oncall
import(
    "gopkg.in/ldap.v2"
    "log"
)