镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Add LdapSessionOptions.CanonicalizeHostName property (#125454) - #136867

Open
Manish-1kumar wants to merge 2 commits into
dotnet:mainfrom
Manish-1kumar:users/Manish-1kumar/ldap-canonicalize-hostname
Open

Manish-1kumar wants to merge 2 commits into
dotnet:mainfrom
Manish-1kumar:users/Manish-1kumar/ldap-canonicalize-hostname

Conversation

@Manish-1kumar

Copy link
Copy Markdown
Contributor

Fixes #125454

Description

Adds the approved LdapSessionOptions.CanonicalizeHostName property in System.DirectoryServices.Protocols:

  • On Linux/Unix, maps to OpenLDAP option LDAP_OPT_X_SASL_NOCANON (0x610b), where LDAP_OPT_X_SASL_NOCANON set to true means canonicalization is disabled (CanonicalizeHostName == false).
  • On Windows, returns true on get (Windows always canonicalizes host names) and throws PlatformNotSupportedException on set, annotated with [UnsupportedOSPlatform(windows)] on setter as approved in API review.
  • Added reference assembly signature in ref/System.DirectoryServices.Protocols.cs.
  • Added unit tests for Windows behavior and Linux/Unix behavior in LdapSessionOptionsTests.cs.

Customer Impact

Allows callers on Linux to disable SASL host name canonicalization when negotiating Kerberos/GSSAPI tickets with LDAP servers.

Regression

No regression; additive API approved by API review.

Testing

  • System.DirectoryServices.Protocols.csproj builds cleanly for all targets (net12.0, net12.0-windows, net12.0-linux, net12.0-osx, etc.).
  • ref/System.DirectoryServices.Protocols.csproj builds cleanly for all frameworks.
  • Unit tests executed and verified with testhost runner:
    • CanonicalizeHostName_GetReturnsTrue_SetThrowsPlatformNotSupportedException: Passed.

Risk

Low; non-breaking new property matching existing patterns in LdapSessionOptions.

Adds the CanonicalizeHostName property to LdapSessionOptions.
On Linux/Unix, maps to OpenLDAP LDAP_OPT_X_SASL_NOCANON option.
On Windows, returns true on get and throws PlatformNotSupportedException on set.

Fixes dotnet#125454
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Nov 2, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
12 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

Passing a 32-bit Win32 BOOL into OpenLDAP ldap_set_option(ld, option, const void *invalue) causes an ABI mismatch on 64-bit platforms, notably under the Mono Interpreter where the upper 32 bits of the pointer argument slot remain uninitialized. OpenLDAP checks if (invalue == LDAP_OPT_OFF) directly against ((void *)0). By changing the interop parameter to IntPtr and passing value ? (IntPtr)1 : IntPtr.Zero, all 64 bits are cleanly cleared for false, allowing boolean option setters such as CanonicalizeHostName to properly toggle back to true/false.
{
get => true;
[UnsupportedOSPlatform("windows")]
set => throw new PlatformNotSupportedException();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API review discussed throwing PlatformNotSupportedException only if setting the value to false, see https://www.youtube.com/watch?v=R-o4X4fSxqM&t=7152s

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-System.DirectoryServices community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants