How to capture User_ID and Client_User_ID in Gen ASP.NET application
search cancel

How to capture User_ID and Client_User_ID in Gen ASP.NET application

book

Article ID: 9510

calendar_today

Updated On: 07-19-2023

Products

Gen Gen - Workstation Toolset Gen - Run Time Distributed

Issue/Introduction

When a Gen application window is generated for ASP.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).

Environment

Gen ASP.NET Application

Resolution

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 an ASP.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 ASP.NET application.

Following is an example of how to populate the ASP.NET application USER_ID with Windows logon user id.

  1. In IIS, open the properties window of the default website.


  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>, edit it to have the following:
    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
            <httpErrors errorMode="Detailed" />
            <directoryBrowse enabled="true" />
        </system.webServer>
        <system.web>
            <!--   <authentication mode="Windows" /> 
              <authorization>
                <allow users="*" />
               </authorization>
            -->
      <authentication mode=Windows />
        :
    </system.web>
    </configuration>

    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.
    ToString();
    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.Gen.exits.dll. Replace the same dll in the application bin directory of the deployed ASP.NET application with this one and retry the trace.

Additional Information

This documentation section includes ASP.NET client user exits like SessionIdExit.cs: Gen™ 8.6 > Distributed Processing > Working with .NET Servers > .NET Server User Exits