How can I capture and display the UserID and ClientUserID in a .NET Gen application?

Document ID : KB000009510
Last Modified Date : 14/02/2018
Show Technical Document Details

When a window is generated in .NET, the User Interface is not picking up either the User_ID field or the Client_User_ID field, both are showing as "USERID" in the Diagram Trace Utility (DTU).


User Id is one of the security related system attributes that are used to identify a user session in a web environment. Depending on user security setup and application design there may be different ways to populate those system attributes. The user id in a .Net application could be the same as the Windows logon user, but it could also be different. Therefore Gen .Net runtime lets the user decide how they want their system attributes to be populated. For this purpose Gen provides a user exit to do that job.

Basically, you need to modify the UserID property of the SessionIdExit.cs to populate the user ID for a .Net application.

Following is an example of how to populate the .Net app user id with Windows logon user id.

  1. In IIS, open the properties window of the default web site.
  2. On the Directory Security tab, click on the Edit button for Anonymous access and authentication control.
  3. Deselect the "Anonymous Access" and check the "Integrated Windows authentication."
  4. In the web.config file, which is located in inetpub wwwroot <app dir>, add following entry:
    <authentication mode=Windows />

    Note: You may want to first stop the ASP.Net state service and WWW publishing services in Windows Services before doing this.
  5. Go to <Gen Dir>\.net\exits\src\amrt and modify the SessionIdExit.cs as follows:

    Add a "using" at the top of the file:
    using System.web;

    Modify the UserId property as follows:

    public static string UserId

    get {
    String currentUser=System.Web.HttpContext.Current.User.Identity.Name.
    int index = currentUser.IndexOf('\\');
    return currentUser.Substring(index+1);
    This will return the user id portion given that the Windows user id is in format <domain>@<user id>
  6. Create the exit assembly by calling makeexits.bat in the Gen\.Net\exits directory. This will create a new CA.AllFusionGen.exits.dll. Replace the same dll in the application bin directory of the deployed .net application with this one and retry the trace.