Kentico macro, working only for admin, (macro signature isssue)

brandon rogers asked on March 29, 2018 22:57

I extended the users account and added a custom field.

I am then using the id to filter a "where" clause on sql data source to get unique data for each user.

{% CMSContext.Current.CurrentUser.NumID #%}

This works correctly because I am a admin and the signature is using my credentials. I checked the console and pulls back the correct data. However when I impersonate a user the query is not working. I tried to use the "@" to disable the security but that s not working either.

Not sure how to get his working.

Thanks!

Correct Answer

Peter Mogilnitski answered on March 30, 2018 01:12

You do not need use CMSContext, it should work without it. In your page with data source add static text web part and put this into text property:

UserName={%CurrentUser.UserName%}<br>
UserID={%CurrentUser.UserID%}<br>
NumID={%CurrentUser.NumID%}<br>

You might just have NumID=null in the DB for a user whom you are running this macro. Check NumID in the DB for UserName and UserID. Check this page with different users. If you open incognito browser window user will be public (Userid = 65).

Check the Kentico event log for macro security errors. If there is none - it is not a security issue. Usually resaving macro solves the issue. If saving does not help you might try to resign all macros

1 votesVote for this answer Unmark Correct answer

Recent Answers


brandon rogers answered on March 30, 2018 15:00

The numID was coming back null for the particular ID. I changed the ID and it's working correctly. I also removed the CMSContext. Thank you!

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.