2

We have an GUI extension tool which connects to .net api running in tridion server which uses coreservice to get required informations.

We have set a default username and password to connect coreservice client in .net api.

So now when user login from tridion user-interface how can we connect to coreservice client using users credentials instead of default username and password in .net api?

(note: we have used Alchemy in other projects in which we don’t require to set default username and password to connect coreservice)

1
  • 1
    Binod please share the Tridion version – Anand NS Jan 18 at 11:54
3

Core Service client, by default uses currently logged on user unless you want to use a different user, like it is explained here in the SDL docs:

https://docs.sdl.com/783502/101707/sdl-tridion-sites-9-1/connecting-to-the-core-service-from--net-as-a-different-user

You may probably have to impersonate it, for example:

if (!String.IsNullOrEmpty(HttpContext.Current.User.Identity.Name))
{      clientCoreServiceSession.Impersonate(HttpContext.Current.User.Identity.Name);
}
3
  • I didnt get it. so you mean when we try to connect our .net api in tridion server through postman request we need to use credentials otherwise if we go through tridion interface we dont need credentials? . this is how we create client: NetTcpBinding netTcpBinding = new NetTcpBinding("netTcpBinding"); CoreServiceClient client = new CoreServiceClient(netTcpBinding, new EndpointAddress(netTcpUrl)); client.ClientCredentials.Windows.ClientCredential = new NetworkCredential(clientUsername, clientPassword); – Binod Jan 19 at 11:38
  • If your .NET client app is using the same application pool as Tridion CME then you do not necessarily need to supply Windows.ClientCredential in your client application code. Could you verify if it using the same application pool as Tridion CME on Tridion server. You might want to also check current user without explicitly setting any user credentials (like you did in your code. For example: HttpContext.Current.User.Identity.Name – Shahid Eqamuddin Jan 19 at 15:36
  • As an alternative to impersonation, if you need to act as the current user, but with different access (e.g. with administrator privileges) consider if the ElevatePrivileges method would help. See the CoreService API documentation or this past question and answer for context. – Alvin Reyes Jan 19 at 21:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.