0
votes

I am confused about the attached image scenario… I need to disable staging logging for users that have a role of externalrole. So, i need to disable logging for 3 items in this case.

enter image description here

This means that i need to make 3 checks. I need help with check #1 and #2.

1: if the user is external user then do not log. I need help with checking for the second part, IsExternal = true here.

2: if the external user is added to the site, then do not log. What would be the check in this case?

3: if the role is external then do not log. This check is good.

Code snippet:

var obj = e.Settings.InfoObj;

          if (
                (obj.ObjectTye == PredefinedObjectType.USER && (Check IsExternal ??????)) ||
                (check that external user did not get added to the website – how to make this check????) ||
(obj.ObjectType == PredefinedObjectType.ROLE && obj.ObjectCodeName.StartsWith("externalrole"))


)

           {

               e.Settings.LogStaging = false;

           }
1

1 Answers

0
votes

You have the object you are already using - var obj = e.Settings.InfoObj;

So, from the "e" object you can get the user ID (e.Settings.InfoObj.ObjectID) and according to the ID you can get the information whether the user is external and whether it belongs to a site, using standard API where you will get the user info by the user ID, then you can check if it is external and also use the CMS.CMSHelper.CurrentUserInfo.IsInSite(string siteName) method to check whether the user is assigned to the site or not

if (obj.ObjectTye == PredefinedObjectType.USER) {

UserInfo updateUser = UserInfoProvider.GetUserInfo(e.Settings.InfoObj.ObjectID);

if ((updateUser.IsExternal) || (updateUser.IsInSite("sitename")) || (updateUser.IsInRole("roleName")) { .... }