I am trying to get the user Id using C# Code as below:
string username = System.Web.HttpContext.Current.User.Identity.Name;
I am getting the username and credetial like this
username:"ACSIND\11111111"
here userid is is '11111111'
but I am not able to get the userid alone from the code.
I have done this in VB as like below:
Option Compare Database
Option Explicit
Private Declare Function GetUserName Lib "ADVAPI32.dll" Alias "GetUserNameA" _
(ByVal lpBuffer As String, nSize As Long) As Long
Public Function GetCurrentUserName() As String
On Error GoTo Err_GetCurrentUserName
Dim lpBuff As String * 25
Dim ret As Long, Username As String
ret = GetUserName(lpBuff, 25)
Username = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1)
GetCurrentUserName = Username & ""
Exit_GetCurrentUserName:
Exit Function
Err_GetCurrentUserName:
MsgBox Err.Description
Resume Exit_GetCurrentUserName
End Function
Please help how to get userId alone in C#