gpt4 book ai didi

c# - 如何获取用户网络登录名?

转载 作者:可可西里 更新时间:2023-11-01 12:42:44 26 4
gpt4 key购买 nike

我正在构建一个 C# 应用程序,我想通过用户名来识别用户。例如,如果我以用户 myusername 身份登录到域 mydomain,我想获取 mydomain\myusername 以便识别用户。

我如何使用 C# 执行此操作?

最佳答案

其实很简单:

Environment.UserName

来自MSDN page :

The UserName property provides part of the credentials associated with computer domain names, as returned by the UserDomainName property. This information is typically represented as DOMAIN\username.

This property can be used to identify the current user to the system and application for security or access purposes. It can also be used to customize a particular application for each user.

您还可以使用 Environment.UserDomainName 获取域名.

关于c# - 如何获取用户网络登录名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/926920/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com