I am trying to retrive the contact details using Tridion.OutboundEmail.ContentManagement API.
After running below code on Page load of user control I am getting error: Access is denied for the user IIS APPPOOL(pool name)
Detailed Error:
System.ServiceModel.FaultException`1[[Tridion.AudienceManagement.DomainModel.ServiceClient.CoreServiceFault, Tridion.AudienceManagement.DomainModel, Version=2.2.0.742, Culture=neutral, PublicKeyToken=ddfc895746e5ee6b]]: Access is denied for the user IIS APPPOOL(pool name)
public void GetContacts_via_filter()
{
var uri = new TcmUri(101, 2, TcmItemTypes.StaticAddressBook);
var addressBook = new StaticAddressBook(uri);
// Got error on this line "UserContext.Current"
var filter = new ContactFilter(UserContext.Current);
var contacts = Contact.GetContacts(filter, addressBook);
foreach (var contact in contacts)
{
Response.Write(contact.ExtendedDetails["NAME"].StringValue);
}
}
My Question here is: 1. How can I change the current user (which is IIS Application pool) to Tridion User (say administrator) 2. I tried initializing the User Context object :
UserContext adminUser = new UserContext("Administartor trustee name");
// Able to get the adminUser.TcmUri and adminUser.UserName
// Response.Write("name is" + adminUser.TcmUri);
var uri = new TcmUri(PublicationID, AddressID, TcmItemTypes.StaticAddressBook);
var addressBook = new StaticAddressBook(uri, adminUser);
var filter = new ContactFilter(adminUser);
var contacts = addressBook.GetContacts(filter, addressBook);
but now got the same error on line "var contacts = addressBook.GetContacts(filter, addressBook);"
Please help 1. How can I run my code under tridion user credential? or 2.where I need to give the access to user IIS APPPOOL(pool name) to fetch the contact details.