简体   繁体   English

使用Active Directory获取PC名称

[英]Get PC-Name using Active directory

i have active directory configured and i have added two user x and y and my domain is DOMAIN. 我配置了活动目录,并添加了两个用户x和y,我的域为DOMAIN。 And i have created an application where i these two can login with their username DOMAIN/X and DOMAIN/Y. 我创建了一个应用程序,这两个应用程序可以使用其用户名DOMAIN / X和DOMAIN / Y登录。 But Here's the scenario i will add the intended user details into the database like their username and password and I want to show a login button without username and password fields who were within my LAN and i should be able to get the PC name and then i will verify it across username which i have saved in Db and get the username and password to validate him. 但是在这种情况下,我会将想要的用户详细信息(如用户名和密码)添加到数据库中,并且我想显示一个登录按钮,其中没有位于我的局域网内的用户名和密码字段,我应该能够获取PC名称,然后我将通过我保存在Db中的用户名进行验证,并获取用户名和密码来验证他。 So basically is there any way to get the Computer name from where the user tried to access the application within my LAN 因此,基本上,有什么方法可以从用户尝试访问我的局域网内的应用程序的地方获取计算机名称。

you can use this piece of code to get the pc name 您可以使用这段代码来获取PC名称

System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString();

but if you will be saving the name of the pc as just the name it might end up having more then one name of the same. 但是,如果您将PC的名称另存为名称,则最终可能会有多个相同的名称。

if its just for each computer you want to register I would suggest going for MAC address 如果只是针对您要注册的每台计算机,我建议您输入MAC地址

not sure exactly how its done but maybe this link will help you 不知道具体如何完成,但也许此链接会为您提供帮助

MAC Address MAC地址

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM