Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connections breakdowns #128

Closed
wants to merge 2 commits into from
Closed

Conversation

definitelynotagoblin
Copy link
Collaborator

Description

A first pass at breaking down monolithic DC connection methods in LDAPUtils

Motivation and Context

Hopefully makes things more legible, testable and maintainable.

How Has This Been Tested?

Will be tested locally

Screenshots (if appropriate):

Types of changes

  • Chore (a change that does not modify the application functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • Documentation updates are needed, and have been made accordingly.
  • I have added and/or updated tests to cover my changes.
  • All new and existing tests passed.
  • My changes include a database migration.

/// <summary>
/// Checks the LDAP exception and throws an appropriate custom exception based on the error code.
/// </summary>
/// <param name="ldapException">The LDAP exception to check.</param>
private static void CheckAndThrowException(LdapException ldapException)
Copy link
Collaborator Author

@definitelynotagoblin definitelynotagoblin Jun 3, 2024

Choose a reason for hiding this comment

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

I don't know that I've actually done anything useful to the legibility of CheckAndThrowException I think I was just looking for an excuse to use a switch statement 🤷

@@ -1498,7 +1525,6 @@ private string ResolveDomainToFullName(string domain)
/// <param name="authType">Auth type to use. Defaults to Kerberos. Use Negotiate for netonly/cross trust(forest) scenarios</param>
/// <param name="globalCatalog">Use global catalog or not</param>
/// <returns>A connected LDAP connection or null</returns>

private async Task<LdapConnectionWrapper> CreateLDAPConnectionWrapper(string domainName = null, bool skipCache = false,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

CreateLDAPConnectionWrapper is still a bit of a monolith, I'll want to iterate this one again.

return true;
}

private void HandleBusyException(ref int retryCount, ref TimeSpan backoffDelay)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not the biggest fan of using refs. Will iterate this and try to remove, but for now I think the current design is simple enough to justify their use here.

}

CheckAndThrowException(connectionResult.Exception);
return null;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Per our new strategy, I should switch this to return a bool and out var

@definitelynotagoblin definitelynotagoblin marked this pull request as draft June 7, 2024 19:17
@github-actions github-actions bot locked and limited conversation to collaborators Sep 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant