DLL_User_ID

    1| using System;
    2| using System.Collections.Generic;
    3| using System.Linq;
    4| using System.Text;
    5| 
    6| //add references
    7| using System.Security.Principal;
    8| 
    9| namespace DLL_User_ID
  10| {
  11|     public class DLL_User_ID_Class
  12|     {
  13|         //Constructor method
  14|         public DLL_User_ID_Class()
  15|         {
  16| 
  17|         }
  18| 
  19|         //Get user ID
  20|         public string Get_User_ID()
  21|         {
  22|             string sUserID = "";
  23|             int iLastSlash = 0;
  24| 
  25|             WindowsIdentity idObj = WindowsIdentity.GetCurrent();
  26| 
  27|             sUserID = idObj.Name;
  28|             iLastSlash = sUserID.LastIndexOf("\\") + 1;
  29|             sUserID = sUserID.Substring(iLastSlash);
  30| 
  31|             return sUserID;
  32|         }
  33|     }//end of class
  34| }