Skip to content

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