Windows凭据中的域名错误 [英] domain name error in windows credentials

查看:117
本文介绍了Windows凭据中的域名错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的每个人

我的Windows应用程序需要有限的用户以管理员身份登录...



所以我用一个用户名制作了一个表格,密码,域名。然后我以管理员身份登录..



问题在于,第一次运行应用程序时,它提供了一个域名NT AUTHORITY,但我的域名是JOHN..



但是在关闭申请并再次打开它之后,它给出了我的真实域名JOHN




i尝试使用此代码获取域名



dear everyone
my windows application needs the limited user to login as administrator...

so i made a form with username, password, domain. then i logged in as administrator ..

the problem is that while running the application for the first time it gives a domain name "NT AUTHORITY" but my domain name is "JOHN"..

but after closing the application and open it again it gives my true domain name "JOHN"


i tried to use this code to get domain name

string domain_name=Environment.UserDomainName;





i也尝试使用此代码



i tried to use also this code

string sTempUser = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
if (sTempUser.IndexOf("\\") != -1)
{
    string[] aryUser = new String[2];
    char[] splitter = { '\\' };
    aryUser = sTempUser.Split(splitter);
   string domain_name = aryUser[0];

}



i想知道如何在第一时间获取我的域名,因为它是在下次执行时program?


i want to know how i can get my domain name IN FIRST time as it is in next time of executing the program??

推荐答案

代码是正确的。我更感兴趣的是知道你做了什么让它以你描述的方式失败。



一个应用程序,当启动时,作为启动它的用户启动。它继承了用户安全令牌。 AT NO TIME是作为另一个用户或系统帐户运行的应用程序,然后切换到当前用户,除非明确编码这样做!即便如此,它将以用户优先启动,然后切换另一个帐户。



如果此应用程序需要用户管理员权限,那么您应该创建一个manfiest对于应用程序并更改<$ href =https://www.google.com/#q=.net+application+manifest+administrator中的 requestedExecutionLevel >这些 [ ^ ]。



不需要用户名和密码框。
The code is correct. I'm more interested in knowing what you did to get it to fail the way you describe.

An application, when launched, is launched as the user that launched it. It inherits the users security token. AT NO TIME is the application running as another user or system account and then switches to the current user, unless explicitly coded to do so! And even then, it will launch as the user first, then switch the another account.

If this application needs the users admin privileges, then you should be creating a manfiest for the app and changing the requestedExecutionLevel as spelled out in these[^].

There's no need for a username and password box for that.


我已经使用用户名,密码和域名,一切都很好..并且工作完美....我不需要制作2个清单





我需要的只是获得正确的域名......否则一切都运行良好
i already made it with username, password and domain and everything is going good..and works perfectly.... i don't have to make 2 manifest


all that i need is to get the right domain name... else everything is working perfectly


这篇关于Windows凭据中的域名错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆