Skip to content

System.DirectoryServices.Protocols - Cannot use SortControl with custom attribute on linux #41618

@null-d3v

Description

@null-d3v

Description

On linux, using SortRequestControl with a custom attribute will cause the search request to fail with the following:

System.DirectoryServices.Protocols.DirectoryOperationException: The server does not support the control. The control is critical.
    at System.DirectoryServices.Protocols.LdapConnection.ConstructResponseAsync(Int32 messageId, LdapOperation operation, ResultAll resultType, TimeSpan requestTimeOut, Boolean exceptionOnTimeOut, Boolean sync)
    at System.DirectoryServices.Protocols.LdapConnection.SendRequest(DirectoryRequest request, TimeSpan requestTimeout)
    at System.DirectoryServices.Protocols.LdapConnection.SendRequest(DirectoryRequest request)

I am able to use a sort control with something basic, like common name.

Sample:

var searchRequest = new SearchRequest(
    $"{LdapOptions.DefaultContainer},{LdapOptions.DnFragment}",
    $"(objectCategory={LdapConstants.UserObjectClass})",
    SearchScope.Subtree,
    LdapConstants.RequestedAttributes);

var sortRequestControl = new SortRequestControl(
    "customAttribute", false);

var vlvRequestControl = new VlvRequestControl(
    0,
    searchOptions.PageSize.Value - 1,
    (searchOptions.PageSize.Value * searchOptions.PageIndex.Value) + 1);

searchRequest.Controls.Add(sortRequestControl);
searchRequest.Controls.Add(vlvRequestControl);

var searchOptionsControl = new SearchOptionsControl(SearchOption.DomainScope);
searchRequest.Controls.Add(searchOptionsControl);

var searchResults = (SearchResponse)LdapConnection.SendRequest(searchRequest);

Configuration

  • .NET 5.0.0-preview.820414.8
  • aspnet:5.0-alpine docker image
  • x86_64
  • libldap 2.4
  • Windows Server 2019 DC

Regression

The exact code is functional when executing from the docker container's Windows host.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.DirectoryServicesenhancementProduct code improvement that does NOT require public API changes/additionsneeds-further-triageIssue has been initially triaged, but needs deeper consideration or reconsiderationos-linuxLinux OS (any supported distro)

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions