@@ -66,6 +66,21 @@ def print_banner():
66
66
)
67
67
68
68
69
+ def is_domain_user (username : str ) -> bool :
70
+ # There are two formats for specifying domain users:
71
+ #
72
+ # 1. User Principal Name (UPN), e.g:
73
+ #
74
+ # <USERNAME>@<DOMAIN>
75
+ #
76
+ # 2. Down-Level Logon Name, e.g:
77
+ #
78
+ # <DOMAIN>\<USERNAME>
79
+ #
80
+ # See https://learn.microsoft.com/en-us/windows/win32/secauthn/user-name-formats
81
+ return "\\ " in username or "@" in username
82
+
83
+
69
84
def check_account_existence (account_name : str ) -> bool :
70
85
"""
71
86
Checks if an account exists on the system by attempting to resolve the account's SID.
@@ -846,16 +861,26 @@ def print_helping_info_and_exit():
846
861
logging .error (f"Not a valid value for Fleet id: { fleet_id } " )
847
862
print_helping_info_and_exit ()
848
863
864
+ # Validate that the --user argument is not a domain user. The installer does not currently support this.
865
+ if is_domain_user (user_name ):
866
+ raise InstallerFailedException (
867
+ "running worker agent as a domain user is not currently supported. You can "
868
+ "have jobs run as a domain user by configuring the queue job run user to specify a "
869
+ "domain user account."
870
+ )
871
+
849
872
# Check that user has Administrator privileges
850
873
if not shell .IsUserAnAdmin ():
851
874
logging .error (f"User does not have Administrator privileges: { os .environ ['USERNAME' ]} " )
852
875
print_helping_info_and_exit ()
853
876
877
+ # Validate that if a windows job user override is specified, that the user exists
854
878
if windows_job_user is not None and not check_account_existence (windows_job_user ):
855
879
raise InstallerFailedException (
856
880
f"Account { windows_job_user } provided for argument windows-job-user does not exist. "
857
881
"Please create the account before proceeding."
858
882
)
883
+ # Validate that if a windows job user override is specified, that it is not the same as the worker agent user
859
884
elif windows_job_user is not None and users_equal (windows_job_user , user_name ):
860
885
raise InstallerFailedException (
861
886
f"Argument for windows-job-user cannot be the same as the worker agent user: { user_name } . "
0 commit comments