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

Add function to escape distinguished names #393

Merged
merged 2 commits into from
Aug 6, 2022

Conversation

tsschaffert
Copy link
Contributor

@tsschaffert tsschaffert commented Aug 5, 2022

This adds a function to escape distinguished names, as described in RFC4514.

The use case is to allow building valid DNs from untrusted input, for example if the group name is user supplied like in the following example:

func ModifyGroup(groupName string) {
	groupCN := fmt.Sprintf("cn=%s,ou=groups,dc=example,dc=org", ldap.EscapeDN(groupName))

	ldap.NewModifyRequest(groupCN, nil)
	...
}

@cpuschma cpuschma self-assigned this Aug 5, 2022
Copy link
Member

@cpuschma cpuschma left a comment

Choose a reason for hiding this comment

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

LGTM! I'll leave the PR open for a few days for others to comment. Thank you for your contribution! 👍

Copy link
Member

@johnweldon johnweldon left a comment

Choose a reason for hiding this comment

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

LGTM; nice!

@cpuschma cpuschma merged commit c7248aa into go-ldap:master Aug 6, 2022
inv2004 pushed a commit to inv2004/ldap that referenced this pull request Jan 17, 2023
* Add function to escape distinguished names
* Test if escaping of trailing space works with multi-byte characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants