Impersonation when using SmartObjectClientServer?

  • 29 June 2012
  • 2 replies
  • 8 views

Badge +8

I'm trying to use the "Process Data Audit" SmartObject to show the history of a particular data field in an ASP.NET application:


SmartObjectClientServer smartObjectServer = new SmartObjectClientServer();
smartObjectServer.CreateConnection();
smartObjectServer.Connection.Open(Settings.SmartObjectServerConnectionString);
SmartObject smartObject = smartObjectServer.GetSmartObject("Process_Data_Audit");
smartObject.MethodToExecute = "List";
smartObject.Properties["ProcInstID"].Value = processInstanceId.ToString();
smartObject.Properties["Data_Name"].Value = k2FieldName;
SmartObjectList results = smartObjectServer.ExecuteList(smartObject);


This works fine when I run it from a console app or the .NET application.


Now I want to move this code to a WCF service (hosted as a Managed Windows Service) for use with AJAX-style operations.  The same code throws SmartObjectException exceptions in this scenario with the following details:


Service: WorkflowReportingService
Service Guid: ef7310e5-b14f-464d-b0f3-a37d6c367620 
Severity: Error 
Error Message: Object reference not set to an instance of an object. 
InnerException Message:


I'm guessing this has something to do with impersonation and the service account the WCF service runs as since the same code works find in other scenarios.  My problem is that I can't seem to find an ImpersonateUser() method in the SourceCode.SmartObjects namespace.


Advice on impersonation (or other workarounds) is appreciated.


2 replies

Badge +10

You would not do the impersonation in the SourceCode.SmartObjects name space.  you would need to do the impersonation with the connectionstringbuilder when connecting to the K2 server.


 


I am looking for a code sample, but if someone has one please post.

Badge +8

I am looking for a code sample, but if someone has one please post.

Thanks for the advice.  Here is a code sample I came up with:


SCConnectionStringBuilder connectionString = new SCConnectionStringBuilder(Settings.SmartObjectServerConnectionString);
connectionString.UserID = @"domainuser";


connectionString.Password = @"pass";


SmartObjectClientServer smartObjectServer = new SmartObjectClientServer();
smartObjectServer.CreateConnection();
smartObjectServer.Connection.Open(connectionString.ConnectionString);
SmartObject smartObject = smartObjectServer.GetSmartObject("Process_Data_Audit");
smartObject.MethodToExecute = "List";
smartObject.Properties["ProcInstID"].Value = processInstanceId.ToString();
smartObject.Properties["Data_Name"].Value = k2FieldName;
SmartObjectList results = smartObjectServer.ExecuteList(smartObject);


What I don't know is what permissions the supplied user needs to have to pull this data correctly.

Reply