检查针对活动目录的用户凭据 [英] Check user credentials against active directory

查看:106
本文介绍了检查针对活动目录的用户凭据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计们。我有一个小问题:我会在用户无法获得交互式访问的PC上使用活动目录检查用户凭据。

IE我无法登录到指定的PC,但我需要插入我的凭据在程序中执行一些禁止当前登录用户的操作。

有一种方法可以检查Active Directory上的用户凭据,无论我输入的是什么PC?

提前致谢



Cesare Cogliandro




我尝试过:



我试图使用DirectorySearcher功能,但如果用户无法在PC上以交互方式登录,则结果为Always False。

解决方案

您是否尝试过使用System.DirectoryServices.AccountManagement,如下所示?如果凭据有效,则ValidateCredentials应返回True。



 Dim IsValid As Boolean = False 
Dim DomainContext As System.DirectoryServices。 AccountManagement.PrincipalContext

'获取相关域的DomainContext对象'
DomainContext = New DirectoryServices.AccountManagement.PrincipalContext(DirectoryServices.AccountManagement.ContextType.Domain,DomainName,DC = Domain,DC = Com,Username,Password)

'验证凭据'
IsValid = DomainContext.ValidateCredentials(NameToCheck,PasswordToCheck)


Hi guys. I have a little problem: i would check user credentials using active directory on a PC on which the user cannot gain interactive access.
I. E. I cannot log onto a given PC, but I need to insert my credentials in a program to perform some operations forbidden to the currently logged on user.
There is a way to check user credentials against Active Directory regardless the PC on which I entered them?
Thanks in advance

Cesare Cogliandro


What I have tried:

I tried to use the "DirectorySearcher" function, but if te user cannot login interactively on the PC, the result is Always False.

解决方案

Have you tried using System.DirectoryServices.AccountManagement as shown below? If the credentials are valid, ValidateCredentials should return True.

Dim IsValid As Boolean=False
Dim DomainContext As System.DirectoryServices.AccountManagement.PrincipalContext

' Get a DomainContext object for the domain in question'
DomainContext = New DirectoryServices.AccountManagement.PrincipalContext(DirectoryServices.AccountManagement.ContextType.Domain, "DomainName", "DC=Domain,DC=Com", "Username", "Password")

' Validate credentials'
IsValid=DomainContext.ValidateCredentials("NameToCheck", "PasswordToCheck")


这篇关于检查针对活动目录的用户凭据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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