Skip to content

[API Proposal]: Add a new CanonicalizeHostName property on LdapSessionOptions #125454

Description

@0xced

Background and motivation

OpenLDAP offers the possibility to configure whether to perform reverse DNS lookups to canonicalize SASL host names.

This can be configured with the SASL_NOCANON option of the LDAP configuration or the LDAP_OPT_X_SASL_NOCANON option of the API.

Configuring this option can be useful, for example to workaround misconfigured DNS PTR records, as explained in ldapsearch command suddenly stopped working on my Mac on Super User.

This option is unfortunately not exposed on the LdapSessionOptions class.

API Proposal

namespace System.DirectoryServices.Protocols;

public class LdapSessionOptions
{
    public bool CanonicalizeHostName { get; set; }
}

API Usage

using var connection = new LdapConnection(ldapHost);
connection.SessionOptions.CanonicalizeHostName = false;

Alternative Designs

I can't think of an alternative design for exposing this new property.

Also note that the implementation would be straightforward:

public bool CanonicalizeHostName
{
    get => !GetBoolValueHelper(LdapOption.LDAP_OPT_X_SASL_NOCANON);
    set => SetBoolValueHelper(LdapOption.LDAP_OPT_X_SASL_NOCANON, !value);
}

It would require moving the GetBoolValueHelper and SetBoolValueHelper from LdapSessionOptions.Linux.cs into LdapSessionOptions.cs and define the new LDAP_OPT_X_SASL_NOCANON enum value (0x610b).

Risks

No risks are associated by introducing this new property. It's purely additional and without getting it or setting it nothing would happen.

Activity

  1. added
    api-suggestionEarly API idea and discussion, it is NOT ready for implementation
    on Mar 11, 2026
  2. dotnet-policy-service commented on Mar 11, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @dotnet/area-extensions-options
    See info in area-owners.md if you want to be subscribed.

  3. 0xced commented on Mar 11, 2026

    @0xced
    ContributorAuthor

    Wrong area, should be area-System.DirectoryServices (the System.DirectoryServices.Protocols namespace in the API proposal section was a pretty strong hint 😁)

    Tagging @jeffhandley, @BRDPM, @grubioe, @jay98014 and @steveharter

  4. dotnet-policy-service commented on Mar 12, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @dotnet/area-extensions-options
    See info in area-owners.md if you want to be subscribed.

  5. dotnet-policy-service commented on Mar 12, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @dotnet/area-system-directoryservices
    See info in area-owners.md if you want to be subscribed.

  6. added 2 commits that reference this issue on Jun 14, 2026
    e80fead
    abc9de7
  7. removed
    api-suggestionEarly API idea and discussion, it is NOT ready for implementation
    on Aug 17, 2026
  8. added this to the Future milestone on Aug 17, 2026
  9. added
    api-ready-for-reviewAPI is ready for review, it is NOT ready for implementation
    and removed
    untriagedNew issue has not been triaged by the area owner
    on Aug 17, 2026
  10. bartonjs commented on Oct 13, 2026

    @bartonjs
    Member

    Video

    • We debated if we wanted a different name based on what the default is, but this type appears to have a mix of default true and default false options already, so a new default true one is fine.
      • In case Windows is actually false, consider changing Linux to also default false.
    namespace System.DirectoryServices.Protocols;
    
    public class LdapSessionOptions
    {
        public bool CanonicalizeHostName
        {
            get; 
            [UnsupportedOSPlatform("windows")]
            set;
        }
    }
  11. added
    api-approvedAPI was approved in API review, it can be implemented
    and removed
    api-ready-for-reviewAPI is ready for review, it is NOT ready for implementation
    on Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions