简体   繁体   English

Intranet NT登录的用户

[英]Intranet NT logged user

I have a welcome head 我有一个欢迎头

<h2>welcome</h2>

But I pretend get welcome to the NT logged user 但是我假装欢迎使用NT登录的用户

this 这个

<h2>Welcome <%response.write request.servervariables("LOGON_USER")%></h2>

gives me the DOMAIN\\USER how I can only show the user? 给我DOMAIN\\USER我怎么只能显示用户? I don't want the domain appears in the text. 我不希望域出现在文本中。

EDITED: 编辑:

I edit this post to not create a new one. 我编辑这篇文章是为了不创建新文章。 I try google but can't find any help I'm getting the correct NT-Logged user. 我尝试使用google,但找不到任何帮助,我正在获取正确的NT记录用户。 However could I get the name of the nt-user... the corresponding one? 但是我能否得到nt-user的名称...对应的名称? Example: Mine NT-User is KFHM. 示例:我的NT用户是KFHM。 but my name in windows is KikoFHM. 但我在Windows中的名字是KikoFHM。 At the moment I'm getting the KFHM but how to get the KikoFHM? 目前我正在获取KFHM,但如何获取KikoFHM?

Just use Split() to separate the Domain from the Username, it uses the \\ as a delimiter creating an Array with two elements, to get just the Username call the second element. 只需使用Split()将域与用户名分开,它使用\\作为定界符,创建一个包含两个元素的数组,只获得用户名调用第二个元素。

Dim username

username = Split(Request.Servervariables("LOGON_USER"), "\")(1)

This is a quick and dirty approach you can expand it and check for the \\ beforehand to avoid errors, something like 这是一种快速而肮脏的方法,您可以对其进行扩展并事先检查\\以免出现错误,例如

Dim cred, domain, username,
cred = Request.ServerVariables("LOGON_USER") & ""
If InStr(1, cred, "\") > 0 Then
  cred = Split(cred, "\")
  domain = cred(0)
  username = cred(1)
End If

If you not interested in structuring your code at all you can always use this quick and dirty piece of code; 如果您根本不希望对代码进行结构化,则可以随时使用此快速而又肮脏的代码。

<%= Split(Request.ServerVariables("LOGON_USER") & "", "\")(1) %>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 “用户&#39;NT AUTHORITY \\ ANONYMOUS LOGON&#39;的登录失败。”到SQL Server 2005 - “Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'.” to SQL Server 2005 在本地Intranet站点中获取客户端计算机和用户名 - Get Client Computer and user name in local intranet site 如果用户登录到其他网站,则自动登录当前网站 - Automatically login to current website if user is logged in to another website 获取 facebook 在 ASP CLASSIC 上登录用户 ID - Get facebook logged in user's ID on ASP CLASSIC NT4选项包 - NT4 Option Pack 经典ASP-ServerXMLHTTP NT身份验证 - Classic ASP - ServerXMLHTTP NT Authentication 使用ASP从Active Directory获取当前登录的用户凭据 - Get currently logged-in user credentials from Active Directory using ASP 如何确定当前登录的用户是否属于classic asp中的特定安全组 - How to find out if a currently logged in user belongs to a specific security group in classic asp 通过LDAP获取登录用户的电子邮件地址:是否提供密码以搜索LDAP? - Get logged on user's email address via LDAP: supply password to search LDAP or not? 如何正确设置开发服务器以在Intranet上使用 - How to properly setup a dev server for use on intranet
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM