Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In order to perform this operation a successful bind must be completed on the connection #142

Open
parthp2107 opened this issue Apr 4, 2023 · 5 comments

Comments

@parthp2107
Copy link

000004DC: LdapErr: DSID-0C090A5A, comment: In order to perform this operation a successful bind must be completed on the connection., data 0, v4f7c

@dirmgr
Copy link
Collaborator

dirmgr commented Apr 4, 2023

There's not really any actual question here, but I assume that you're encountering this error and would like to know why.

First, that error is coming from the directory server (Active Directory by the looks of it), and not from the LDAP SDK itself.

Second, unlike many messages from Active Directory, this one is actually pretty clear. As the message states, the client needs to send a bind request to authenticate the connection before it will allow the operation you've requested.

@parthp2107
Copy link
Author

Can you please guide me on how I can perform a bind request to authenticate the connection?

@dirmgr
Copy link
Collaborator

dirmgr commented Apr 4, 2023

Use the LDAPConnection.bind method to submit an appropriate bind request. The easiest and most common type of bind is an LDAP simple bind, which authenticates with the DN and password for the user as whom you're trying to authenticate. If you don't have the DN and password for a user account, then you'll need to talk to a server administrator.

Also, binds are one of the most fundamental concepts in LDAP. If you don't really understand them, then you should probably spend some time learning more about LDAP before proceeding.

@parthp2107
Copy link
Author

ldapConnectionPool.bind(storedUser.getName(), reqPassword);

I am using this in my code. Is this what you are suggesting to use?
I have the DN and the password.

@dirmgr
Copy link
Collaborator

dirmgr commented Apr 4, 2023

That call will perform a bind on a connection from the connection pool, but the problem is that if you subsequently try to perform another operation that requires a previous bind, if your connection pool has more than one connection, then there's no guarantee that it will choose the same connection for the bind as another operation that follows it.

If you want to use the same credentials for all operations processed in the connection pool, then the best option would be to provide the credentials at the time you create the connection pool. The way that you do this depends on how you're creating the pool.

  • If you create a connection pool from an initial connection and tell it to just use more of those, then you should perform the bind on that connection before creating the pool.
  • If you create a connection pool from a server set, then you can also provide a bind request at that time.

On the other hand, if you want most connections in the pool to either be unauthenticated, or authenticated as a different user, then you have a couple of options. But if the bind should just be considered temporary, then you'll probably need to check a connection out of the pool using the getConnection method, use that connection to perform the bind and the subsequent operations that need to be authenticated as that user, then return the connection back to the pool using the releaseAndReAuthenticateConnection method. The releaseAndReAuthenticateConnection method will attempt to revert the connection back to the authentication state it had when the connection was initially established by the pool (and if it was initially unauthenticated, then the pool will use an anonymous simple bind to try to achieve that).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants