Contents
Contents

Running IB Code as a Different User

Struggling to bridge the legacy gap? Cedar Hills Group provides specialized PeopleSoft integration consulting to help teams design, build, and optimize their connection strategies.

PeopleCode is always running under some user ID context. In integration broker handlers, the user context is typically the “default user ID” from the node definition. There are times when you may need to change the user context, for example when invoking a component interface that has application-level security or search records with data security.

SwitchUser in Synchronous Handlers (OnRequest)

If you need to switch user context in a synchronous OnRequest handler, you can use the SwitchUser built-in function with a PS_TOKEN cookie value:

import PS_PT:Integration:IRequestHandler;

class INBOUND_TESTER implements PS_PT:Integration:IRequestHandler
   method onRequest(&MSG As Message) Returns Message;
   method getCookieFromRequest(&MSG As Message, &cookieName As string) Returns string;
end-class;

method onRequest
   /+ &MSG as Message +/
   /+ Returns Message +/
   /+ Extends/implements PS_PT:Integration:IRequestHandler.OnRequest +/

   Local XmlDoc &xmlDocInbound;
   Local XmlNode &requestRootNode;
   &xmlDocInbound = &MSG.GetXmlDoc();
   &requestRootNode = &xmlDocInbound.DocumentElement;

   /* Setup response xml body */
   Local Message &response;
   &response = CreateMessage(Operation.CHG_TEST, %IntBroker_Response);
   Local XmlDoc &xmlout;
   Local XmlNode &childNode;
   &xmlout = CreateXmlDoc("");

   &childNode = &xmlout.DocumentElement.AddElement("user_before").AddText(%OperatorId);
   Local string &cValue;

   &cValue = %This.getCookieFromRequest(&MSG, "PS_TOKEN");

   If SwitchUser("", "", &cValue, "") Then
      &childNode = &xmlout.DocumentElement.AddElement("message").AddText("User Switched");
   Else
      /* SwitchUser Failed - Token probably invalid */
      &childNode = &xmlout.DocumentElement.AddElement("message").AddText("Could not Switch to user identified by token");
   End-If;

   &childNode = &xmlout.DocumentElement.AddElement("user_after_switch").AddText(%OperatorId);
   &response.SetXmlDoc(&xmlout);
   Return &response;

end-method;

After a successful switch, you can invoke component interfaces as the switched user and any audits or security in the underlying code will execute under that user’s context.

SwitchAsyncEventUserContext for Asynchronous Messages

For asynchronous messages, PeopleTools provides a method on the %IntBroker class to change the user context. This is useful when subscription PeopleCode needs to run component interfaces that require different security than what the triggering user has.

For example, a student saving data on a self-service page may trigger an integration broker message, but the subscription code needs component interface and row-level security that the student should not have.

Local boolean &bswitchUserReturn = %IntBroker.SwitchAsyncEventUserContext("PS", "ENG");

Starting in PeopleTools 8.48, subscription code runs as the user who triggered the business event. Before 8.48, it ran as the default node user. The SwitchAsyncEventUserContext method lets you override this behavior when needed.

Author Profile
Chris Malek

Chris Malek is a PeopleTools® Technical Consultant with over two decades of experience. He is available for consulting engagements.

Work with Chris
Subscribe to Updates
SWS Bolt-On
PeopleSoft Simple Web Services

SWS turns SQL into production REST APIs — ready for AI, modern apps, and partner integrations. One install, unlimited potential.

  • Configuration-driven, no coding required
  • JSON, XML, and CSV output
  • Works across all PeopleSoft pillars
  • Built on 25+ years of PeopleSoft expertise
Read More & Purchase
SWS Bolt-On
PeopleSoft Simple Web Services

A powerful PeopleSoft bolt-on that makes REST web services easy. You bring the SQL, SWS handles the rest.

  • Go from idea to production in minutes
  • Zero code migrations after install
  • JSON, XML, and CSV output supported
  • No PeopleCode or Integration Broker expertise required
Read More & Purchase
SWS Bolt-On
PeopleSoft Simple Web Services

Traditional PeopleSoft web services cost $3,600–$13,000 each to develop. SWS deploys production REST APIs in under 5 minutes through configuration alone.

  • No PeopleCode or Integration Broker expertise required
  • Works across Campus Solutions, HCM, and Financials
  • Built-in pagination, caching, and nested data structures
  • Trusted by institutions across higher education and government
Read More & Purchase
SWS Bolt-On
PeopleSoft Simple Web Services

Turn PeopleSoft data into clean REST APIs for AI integrations, modern applications, and vendor data feeds. Configuration-driven — no PeopleCode required.

  • Deploy production APIs in under 5 minutes
  • AI and LLM ready (RAG, chatbots, intelligent search)
  • JSON, XML, and CSV output
  • Zero modifications to delivered PeopleSoft objects
Read More & Purchase
psLens Platform
psLens Operations & Intelligence

Look up any record, field, page, or component, audit security, and monitor Integration Broker across every database — in seconds.

  • 30+ object types browsable
  • 16 real-time alert types
  • Read-only by design
  • No App Designer or SQL required
Learn More
psLens Platform
psLens Operations & Intelligence

A web console built for the PeopleSoft community — operational monitoring, security auditing, and metadata browsing in one tool.

  • Sub-second object search
  • Catch stuck IB messages before users do
  • Audit service permissions from one screen
  • Works in any browser
Learn More
psLens Platform
psLens Operations & Intelligence

On-demand security and operational reports for your PeopleSoft environment — no client install required.

  • 14 on-demand reports
  • Markdown export for AI/LLM workflows
  • No shared tenancy
  • Built on 25+ years of PeopleSoft expertise
Learn More
psLens Platform
psLens Operations & Intelligence

Research any PeopleSoft object and monitor system health from a single browser tab — no App Designer, no SQL.

  • 30+ PeopleSoft object types browsable
  • Real-time alerts before users report problems
  • Read-only and secure
  • Private alpha — early access now
Learn More