Add LDAP authentication support to LdapOperations#55
Open
thegreatmhn wants to merge 6 commits into
Open
Conversation
add authentication module to ldapoperation.
Update LdapOperations.cs
Update EnumPkiObjects.cs
Update EnumTemplates.cs
Collaborator
|
Looks good, but it looks like you only added it to Enumerate Templates and Enumerate PKI objects (and omitted the masked password input querying on the latter). What about Enumerate CAs ? :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Right now LdapOperations can only talk to LDAP as whoever is currently logged in — there's no way to pass in a different username/password. This PR adds that.
What changed:
Added a small private helper, GetDirectoryEntry(), that builds the DirectoryEntry and applies the username/password if they were given.
Swapped all the methods (GetPKIObjects, GetEnterpriseCAs, GetCertificateTemplates, etc.) to use this helper instead of creating DirectoryEntry objects on their own.
Why:
Sometimes you need to run this as a specific account instead of the current user (e.g. from a non-domain-joined box, or with a service account). There was no clean way to do that before.
Does this break anything?
Nope — if you don't pass a username/password, it works exactly like before (current user auth). If you do pass them, they're now actually used everywhere instead of just in the constructor.
Tested:
Ran it with --username/--password and confirmed the bind works.
Ran it with no credentials and confirmed it still works as current user.