如何获取登录用户的用户ID?

时间:2013-11-28 07:16:54

标签: vb.net

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Dim strsql As String = "select UserID from tGNLoginuser where userID=" & UserID
    UserID = DBH.getResult(strsql) ''library for executing query
    clearData()
End Sub

如何获取登录用户的用户标识?是否有任何命令在Windows窗体中获取userID

1 个答案:

答案 0 :(得分:0)

使用此命令获取登录的用户名:

Environment.UserName

还有:

WindowsIdentity.GetCurrent

返回表示当前Windows用户的WindowsIdentity对象。

WindowsIdentity.GetCurrent

Environment.UserName