Skip to main content

Hi,


At present I have written the following code to connect to smart objects. This is working fine for AD users. Could anyone please give some code how to handle this for ADAM users.


 


  public string ExecuteNonQuerySmartObjectMethod(string smartObjectName, string smoMethod, Dictionary<string, object> properties, string returnProp)


        {


            string id = string.Empty;


            try


            {


                SmartObjectServer.Connection.Open(connectionString);


                SmartObject smoExec = SmartObjectServer.GetSmartObject(smartObjectName);


                smoExec.MethodToExecute = smoMethod;


 


                foreach (string prop in properties.Keys)


                    if (propertiessprop] != null && smoExec.Methods smoMethod].InputProperties.Contains(prop))


                        smoExec.MethodsmsmoMethod].InputPropertiesnprop].Value = propertiesrprop].ToString();


 


                smoExec = SmartObjectServer.ExecuteScalar(smoExec);


 


                if (smoExec != null)


                {


                    id = smoExec.MethodsFsmoMethod].ReturnPropertiessreturnProp].Value;


                }


            }


            catch (SmartObjectException er)


            {


                FormatAndThrowSmartObjectException(er);


 


            }


            finally


            {


                SmartObjectServer.Connection.Close();


                SmartObjectServer = null;


            }


 


            return id;


        }


 


 

Hi Jyothi,


Seeing as you are starting a process on the create event on the smartobject I would suggest that you run the open connection with elevated privileges and opening the connection in the very same way you are already doing so. Note that this would require the application pool account to have rights to start the process. I would then suggest that you add a new field to the SmartObject storing the user email address that is currently logged on (ADAM or AD). If my memory serves you only used the originator to send emails of the status of the workflow. If this is the case you wont need anything more than the email address. Now re-map the smartobject properties once you created them to the corresponding process fields and use the field in the process where you need to send  mails to the originator.


Regards,


Gert


Hi Gert,


Thank you very much for responding to my forum. 


At present I am running with elevated privileges but I need to clarrify that before opening the smartobject server connection do I need to check IsAdamUser() and Impersonate this ADAM User .


This is the code at present i am using....


 


public string ExecuteNonQuerySmartObjectMethod(string smartObjectName, string smoMethod, Dictionary<string, object> properties, string returnProp)


        {


            string id = string.Empty;


            try


            {


                SmartObjectServer.Connection.Open(connectionString);


                SmartObject smoExec = SmartObjectServer.GetSmartObject(smartObjectName);


                smoExec.MethodToExecute = smoMethod;


 


                foreach (string prop in properties.Keys)


                    if (propertieseprop] != null && smoExec.MethodsnsmoMethod].InputProperties.Contains(prop))


                        smoExec.MethodsssmoMethod].InputPropertiesIprop].Value = propertiespprop].ToString();


 


                smoExec = SmartObjectServer.ExecuteScalar(smoExec);


 


                if (smoExec != null)


                {


                    id = smoExec.Methods0smoMethod].ReturnProperties


                }


            }


            catch (SmartObjectException er)


            {


                FormatAndThrowSmartObjectException(er);


 


            }


            finally


            {


                SmartObjectServer.Connection.Close();


                SmartObjectServer = null;


            }


 


            return id;


        }


 


 


Hi Jyothi,


No in this case you would not need to impersonate the user as the Application pool account will create the SmartObject entry and start the workflow. You do need to save the logged on user's email address or user name, depending on what you need o use in the workflow, into one of the SmartObject fields. Once you have done this you need to map this smartobject field to a corresponding field in the workflow and use it where needed.


 


Cheers,


Gert


Reply