From 46efd8542d419db6e3bbce6c99031ab64308ade1 Mon Sep 17 00:00:00 2001 From: srb3 Date: Fri, 14 Feb 2020 18:46:34 +0000 Subject: simplify regex and add specification links Signed-off-by: srb3 --- lib/chef/resource/windows_ad_join.rb | 7 +++++-- 1 file 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}" -- cgit v1.2.1