Check for null before accessing the current user details.

Identified while working on the unit tests.

Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
Konstantina Chremmou 2019-06-04 00:29:37 +01:00 committed by Mihaela Stoica
parent 6b15a45cd9
commit 3f3302a6b4

View File

@ -206,10 +206,10 @@ namespace XenAPI
if (IsLocalSuperuser) if (IsLocalSuperuser)
return Messages.AD_LOCAL_ROOT_ACCOUNT; return Messages.AD_LOCAL_ROOT_ACCOUNT;
if (!string.IsNullOrEmpty(CurrentUserDetails.UserDisplayName)) if (CurrentUserDetails != null && !string.IsNullOrEmpty(CurrentUserDetails.UserDisplayName))
return CurrentUserDetails.UserDisplayName.Ellipsise(50); return CurrentUserDetails.UserDisplayName.Ellipsise(50);
if (!string.IsNullOrEmpty(CurrentUserDetails.UserName)) if (CurrentUserDetails != null && !string.IsNullOrEmpty(CurrentUserDetails.UserName))
return CurrentUserDetails.UserName.Ellipsise(50); return CurrentUserDetails.UserName.Ellipsise(50);
return Messages.UNKNOWN_AD_USER; return Messages.UNKNOWN_AD_USER;
@ -223,7 +223,7 @@ namespace XenAPI
if (IsLocalSuperuser) if (IsLocalSuperuser)
return Messages.AD_LOCAL_ROOT_ACCOUNT; return Messages.AD_LOCAL_ROOT_ACCOUNT;
if (!string.IsNullOrEmpty(CurrentUserDetails.UserName)) if (CurrentUserDetails != null && !string.IsNullOrEmpty(CurrentUserDetails.UserName))
return CurrentUserDetails.UserName; return CurrentUserDetails.UserName;
return UserSid; return UserSid;