How to get the user Id of the currently logged use

2019-05-26 01:06发布

I implemented a Ribbon tool bar button in the Tridion. As part of that I need to loop through the some components, which requires a valid session.

To create a session in the Tridion I require a User Id. How to get the User Id of the current user(windows User Id)?

Will the following command help us to get the user info? If so please let me know the usage of the command.

getJsonUserSettings();

Thanks in advance. Early response is appreciated.

2条回答
萌系小妹纸
2楼-- · 2019-05-26 01:19

In c# you can use Tridion.Web.UI.Core.Utils.GetUserName()

This will return the LOGIN name of the user, which you need - for instance - to impersonate.

I fumbled for a few seconds in Chrome's Console and came up with this for the user name - there may be an easier way to do it.

Tridion.ContentManager.UserSettings.getInstance().getUserName()

EDIT: As mentioned by Frank, this is a duplicate of How can I retrieve TCM URI of the currently logged in user in JavaScript code?

Not a bad idea to start searching before posting...

查看更多
女痞
3楼-- · 2019-05-26 01:20

Try this way to get the User ID:

Tridion.UI.UserSettings.getJsonUserSettings(true).User["@ID"]
查看更多
登录 后发表回答