summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsrb3 <sbrown@chef.io>2020-02-14 18:46:34 +0000
committersrb3 <sbrown@chef.io>2020-02-14 18:46:34 +0000
commit46efd8542d419db6e3bbce6c99031ab64308ade1 (patch)
tree6b99c93c68df4bffb8a7c750c2041792b8a4b7f7
parent93a80dc696fb50f088471ab1c71ccd902a433cdb (diff)
downloadchef-46efd8542d419db6e3bbce6c99031ab64308ade1.tar.gz
simplify regex and add specification links
Signed-off-by: srb3 <sbrown@chef.io>
-rw-r--r--lib/chef/resource/windows_ad_join.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/chef/resource/windows_ad_join.rb b/lib/chef/resource/windows_ad_join.rb
index 037b527d33..b807abaa93 100644
--- a/lib/chef/resource/windows_ad_join.rb
+++ b/lib/chef/resource/windows_ad_join.rb
@@ -174,9 +174,12 @@ class Chef
# if the domain_user property contains an @ symbol followed by any number of non white space characheters
# then we assume it is a user from another domain than the one specifed in the resource domain_name property.
# if this is the case we do not append the domain_name property to the domain_user property
- # regex: https://rubular.com/r/VzupyBWemC8MMM
+ # the domain_user and domain_name form the UPN (userPrincipalName)
+ # The specification for the UPN format is RFC 822
+ # links: https://docs.microsoft.com/en-us/windows/win32/ad/naming-properties#userprincipalname https://tools.ietf.org/html/rfc822
+ # regex: https://rubular.com/r/isAWojpTMKzlnp
def sanitize_usename
- if new_resource.domain_user =~ /^\S*@\S*$/
+ if new_resource.domain_user =~ /@/
new_resource.domain_user
else
"#{new_resource.domain_user}@#{new_resource.domain_name}"