How to enable a user to impersonate in Tridion 2009?

I am trying to use the Tridion ContentManagment API to retrieve taxonomy categories and keywords, but I am running the Access denied error.

I have the following method:

public Dictionary<string, string> GetKeywords(string tcmUri) { var result = new Dictionary<string, string>(); try { // _settings.ImpersonationUser = "MYDOMAIN/myusername" using (var session = new Session(_settings.ImpersonationUser)) { var category = new Category(new TcmUri(tcmUri), session); var keywords = category.GetKeywords(new Filter()); if (keywords != null && keywords.Count > 0) { foreach (var keyword in keywords) { result.Add(keyword.Id.ToString(), keyword.Title); } } } } catch (Exception ex) { Logger.Log.Error( "Failed to retrieve keywords for '{0}'.".FormatWith(tcmUri), ex); } return result; } 

The user, I have _settings.ImpersonationUser , has access to the Tridion Content Manager, is configured as an administrator, and added to impersonation users in the SDL Tridion Content Manager configuration snap-in.

The error I am getting is the following:

 System.Runtime.InteropServices.COMException (0x80040302): <?xml version="1.0"?> <tcm:Error xmlns:tcm="http://www.tridion.com/ContentManager/5.0" ErrorCode="80040302" Category="16" Source="Kernel" Severity="2"> <tcm:Line ErrorCode="80040302" Cause="true" MessageID="16226"> <![CDATA[Access denied for the user MYDOMAIN\myuser.]] <tcm:Token>MYDOMAIN\myuser</tcm:Token> </tcm:Line> <tcm:Details> <tcm:CallStack> <tcm:Location>SystemBLST.GetUserContext</tcm:Location> <tcm:Location>SystemBLST.IBLSecurityST_GetUserContext</tcm:Location> </tcm:CallStack> </tcm:Details> </tcm:Error> 

Does anyone have the keys to what I'm doing wrong? Thanks in advance!

+6
source share
1 answer

Here are a few things to understand when it comes to impersonation and Tridion ...

  • The user executing the code must not have access to the Tridion.
  • The user executing the code must be configured as a valid "Impersonation User"
  • The user issuing the code must be a valid Tridion user.

If all these 3 conditions are true, the impersonation will be performed.

By executing the code, I mean the Windows account under which the code is executed. If this account has access to Tridion, you do not need to use impersonation.

Hope this helps.

+11
source

Source: https://habr.com/ru/post/914511/


All Articles