To find the appropriate database user credentials for CICS transactions or batch jobs, the SQL Server XA switch module issues the Transact-SQL EXECUTE AS statement. For the EXECUTE AS statement to work properly, you must include a GRANT IMPERSONATE statement in your SQL Server login/user ID security environment. This enables the xa_open user ID to impersonate the appropriate database user ID.
The following is provided as a simple example. Your security and database environment might dictate a different implementation. Please review the Microsoft documentation on the EXECUTE AS statement and other related topics before implementing your solution:
CREATE LOGIN [XAOPENUSER] WITH PASSWORD=N'XAOPEN', DEFAULT_DATABASE=[mfdb], DEFAULT_LANGUAGE=[us_english], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF CREATE SCHEMA [XAOPENUSER] CREATE USER [XAOPENUSER] FOR LOGIN [XAOPENUSER] WITH DEFAULT_SCHEMA=[XAOPENUSER]
CREATE SCHEMA [FRITZ] CREATE USER [FRITZ] WITHOUT LOGIN WITH DEFAULT_SCHEMA=[FRITZ]
CREATE SCHEMA [ALLIE] CREATE USER [ALLIE] FOR LOGIN [ALLIE] WITH DEFAULT_SCHEMA=[ALLIE]
ALTER ROLE [db_owner] ADD MEMBER [SCOTT] ALTER ROLE [db_owner] ADD MEMBER [ALLIE] GRANT SELECT ON SCHEMA1.TABLE1 TO SCOTT GRANT ALL ON SCHEMA1.TABLE1 TO ALLIE
GRANT IMPERSONATE ON USER:: FRITZ TO XAOPENUSER; GRANT IMPERSONATE ON USER:: ALLIE TO XAOPENUSER;