Skip to content

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

@0xced

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    api-suggestionEarly API idea and discussion, it is NOT ready for implementationarea-Extensions-OptionsuntriagedNew issue has not been triaged by the area owner

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions