Skip to content

Conversation

JasonDebug
Copy link
Contributor

@JasonDebug JasonDebug commented Aug 1, 2023

Fixes #65894

LoadDomainInfo builds an LDAP Uri that ignores the requested port. If LDAPS/636 is requested, traffic still goes to 389 for this request. For environments where port 389 is blocked, this causes calls such as GroupPrincipal.GetMembers() to fail when the group is Domain Local or Universal. We do not seem to call LoadDomainInfo for Global groups.

This PR will use the specified port for the call, 389 if no port is specified, or 636 if LDAPS is specified.

dotnet#65894

LoadDomainInfo builds an LDAP Uri that ignores the requested port.  If LDAPS/636 is requested, traffic still goes to 389 for this request.
@ghost ghost added area-System.DirectoryServices community-contribution Indicates that the PR has been added by a community member labels Aug 1, 2023
@ghost
Copy link

ghost commented Aug 1, 2023

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

Issue Details

#65894

LoadDomainInfo builds an LDAP Uri that ignores the requested port. If LDAPS/636 is requested, traffic still goes to 389 for this request. For environments where port 389 is blocked, this causes calls such as GroupPrincipal.GetMembers() to fail.

This PR will use the specified port for the call, 389 if no port is specified, or 636 if LDAPS is specified.

Author: JasonDebug
Assignees: -
Labels:

area-System.DirectoryServices, community-contribution

Milestone: -

Fixing CA1311
@steveharter
Copy link
Contributor

PTAL @jay98014 and @kumarravi

@ericstj ericstj assigned jay98014 and unassigned jay98014 Sep 5, 2023
@ericstj ericstj requested review from kumarravik78c and removed request for kumarravi September 6, 2023 16:17
Copy link
Member

@kumarravik78c kumarravik78c left a comment

Choose a reason for hiding this comment

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

I have validated this PR on my local set up and made sure this fixes the issue, hence approving.

@steveharter steveharter self-requested a review September 13, 2023 20:08
Copy link
Contributor

@steveharter steveharter left a comment

Choose a reason for hiding this comment

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

Approving based on approval from @kumarravik78c

@steveharter steveharter merged commit a4b8dc2 into dotnet:main Sep 13, 2023

// Pull the requested port number
Uri ldapUri = new Uri(this.ctxBase.Path);
int port = ldapUri.Port != -1 ? ldapUri.Port : (ldapUri.Scheme.ToUpperInvariant() == "LDAPS" ? 636 : 389);
Copy link
Contributor

Choose a reason for hiding this comment

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

String.Equals(..., StringComparison.OrdinalIgnoreCase) avoids an unnecessary allocation.

@ghost ghost locked as resolved and limited conversation to collaborators Oct 14, 2023
@JasonDebug JasonDebug deleted the bugfix/LoadDomainInfo-ignores-portnumber branch November 20, 2023 16:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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.

Ldap GetMembers working over 389 port

5 participants