Code Monkey home page Code Monkey logo

Comments (5)

korylprince avatar korylprince commented on August 18, 2024

Can you please provide me with some example code that creates the error?

That error indicates that you performed a search that should have returned a unique LDAP entry, but either returned none or more than one.

I'll need to see your code to know if there's a problem with my code, your code, or your environment.

from go-ad-auth.

SanjayMW avatar SanjayMW commented on August 18, 2024

Hi
Here I am providing the username and password.
Code ---->

func Login(username, password, group string, config *Config) (bool, error) {
ok, _, err := LoginWithAttrs(username, password, group, config, nil)
return ok, err
}

/*
LoginWithAttrs will function exectly like Login, but will return a given
list of attributes for the user if login is successful.
*/
func LoginWithAttrs(username, password, group string, config *Config, attrs []string) (bool, map[string][]string, error) {
if password == "" {
return false, nil, nil
}
conn, err := config.Connect()
if err != nil {
return false, nil, err
}
defer conn.Close()

domain, err := getDomain(config.BaseDN)
if err != nil {
	return false, nil, err
}

var upn string
if _, err = mail.ParseAddress(username); err == nil {
	upn = username
} else {
	upn = fmt.Sprintf("%s@%s", username, domain)
}

lErr := conn.Bind(upn, password)
if lErr != nil {
	if config.Debug {
		log.Printf("DEBUG: LDAP Error %v\n", lErr)
	}
	if e, ok := lErr.(*ldap.Error); ok {
		if e.ResultCode == ldap.LDAPResultInvalidCredentials {
			return false, nil, nil
		}
	}
	return false, nil, lErr
}
if group != "" {
	return inGroup(upn, group, config, conn, attrs)
}
entryAttrs, err := getAttrs(upn, config, conn, attrs)

fmt.Println(upn, " ", config, " ", conn, " ", attrs)
if err != nil {
	return false, nil, err
}
return true, entryAttrs, nil

}

In fetching the entry attributes. This error occurs.

from go-ad-auth.

korylprince avatar korylprince commented on August 18, 2024

It looks like you're trying to use the v1 version of the library which is deprecated, not going to be updated, and not well tested.

Can you please try using the v2 version of the library? It's completely rewritten and fully tested. I think there's a good chance that whatever bug you've hit in v1 is likely fixed already in v2. If not, it will be much easier to find in v2.

It's not a drop-in replacement, but it's pretty easy swap everything over.

from go-ad-auth.

korylprince avatar korylprince commented on August 18, 2024

Closing due to no response. Feel free to reopen if you're still having this issue.

from go-ad-auth.

SanjayMW avatar SanjayMW commented on August 18, 2024

Hey this worked..thanks @korylprince .

from go-ad-auth.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.