ldap4net: In order to perform this operation a successful bind must be completed on the connection

Describe the bug During Bind error out "LdapForNet.LdapOperationsErrorException: Operations error. 000004DC: LdapErr: DSID-0C0907E9, comment: In order to perform this operation a successful bind must be completed on the connection., data 0, v2580. Result: 1. Method: ldap_parse_result. Details: ErrorMessage: 000004DC: LdapErr: DSID-0C0907E9, comment: In order to perform this operation a successful bind must be completed on the connection., data 0, v2580\n

To Reproduce Write a .net core 3.1 app to query for a CN based resource - on BIND it is breaking on server container where as working fine in local docker Linux container

Expected behavior Bind should be successful

Desktop (please complete the following information):

  • OS: [e.g. iOS] LINUX Docker container
  • Library version [e.g. 2.3] 2.7.11
  • .NET\core\mono version [e.g. 4.6, 3.1] .net core 3.1
  • LDAP server [e.g. Active Directory, OpenLdap] AD

Additional context I have tested same code in local with Docker Linux container which worked just fine but when deployed on server and ran API it throw above error - curious to know what is happening. I am using SIMPLE authentication method using credentials.

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Comments: 21 (8 by maintainers)

Most upvoted comments

Same issue here. What I’ve observed by debugging into the LdapConnection class is that the search I’m doing actually succeeds, but comes back with the operations error.

public DirectoryResponse SendRequest(DirectoryRequest directoryRequest)
{
    ThrowIfNotBound();
    var requestHandler = SendRequest(directoryRequest, out var messageId);
    var response = ProcessResponse(directoryRequest, requestHandler, messageId, CancellationToken.None);
    ThrowIfResponseError(response);
    return response;
}

The exception is thrown by ThrowIfResponseError() once it pulls out the response code, even though there are entries returned by the search. I would like to be able to follow the earlier suggestion of checking the return count of records, but clients don’t get the chance since the exception happens first.

Update: Turns out changing the port on Connect() from 389 to 3268 made all the difference. With that change, it’s working.

I managed to fix this, you need to turn off referrals by:

cn.SetOption(LdapOption.LDAP_OPT_REFERRALS, IntPtr.Zero);

Yes, works on two controllers