From 3f3302a6b457a4a415fd043fd166b745652d6c68 Mon Sep 17 00:00:00 2001 From: Konstantina Chremmou Date: Tue, 4 Jun 2019 00:29:37 +0100 Subject: [PATCH] Check for null before accessing the current user details. Identified while working on the unit tests. Signed-off-by: Konstantina Chremmou --- XenModel/XenAPI-Extensions/Session.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/XenModel/XenAPI-Extensions/Session.cs b/XenModel/XenAPI-Extensions/Session.cs index 54ac36bad..a6bfa4a1f 100644 --- a/XenModel/XenAPI-Extensions/Session.cs +++ b/XenModel/XenAPI-Extensions/Session.cs @@ -206,10 +206,10 @@ namespace XenAPI if (IsLocalSuperuser) return Messages.AD_LOCAL_ROOT_ACCOUNT; - if (!string.IsNullOrEmpty(CurrentUserDetails.UserDisplayName)) + if (CurrentUserDetails != null && !string.IsNullOrEmpty(CurrentUserDetails.UserDisplayName)) return CurrentUserDetails.UserDisplayName.Ellipsise(50); - if (!string.IsNullOrEmpty(CurrentUserDetails.UserName)) + if (CurrentUserDetails != null && !string.IsNullOrEmpty(CurrentUserDetails.UserName)) return CurrentUserDetails.UserName.Ellipsise(50); return Messages.UNKNOWN_AD_USER; @@ -223,7 +223,7 @@ namespace XenAPI if (IsLocalSuperuser) return Messages.AD_LOCAL_ROOT_ACCOUNT; - if (!string.IsNullOrEmpty(CurrentUserDetails.UserName)) + if (CurrentUserDetails != null && !string.IsNullOrEmpty(CurrentUserDetails.UserName)) return CurrentUserDetails.UserName; return UserSid;