Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
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.
Posted
Updated 6-Nov-18 17:26pm
Comments
Alek Massey 10-Sep-18 10:53am    
The word you want is impersonation.

User Impersonation in .NET[^]

1 solution

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")
 
Share this answer
 
Comments
cesare.cogliandro@teletu.it 5-Feb-19 11:21am    
I tried to use that function, but the result is Always the same: if the user cannot login on the PC requesting the validation, the answer is Always false. An example about the situation: user "A" logged on a PC, launch a software which requires autentication and the autentication is obtained from active directory.
If another user "B" needs to perform some tasks on this application on this machine (but cannot make login from that PC) the application (not the PC) should be able to grant access with his credentials to the tasks permitted to that user.
We have two levels of autentication: the first on the PC, the second on my software and this secon autentications should be possible regardless the user could or not lo on to the PC.
In brief, I ned a function that asks to active directory if a couple of credentials (username and password, obviously) are valid regardless ther PC context from which the request starts.
Thanks in advance.
W.G.C. 10-Mar-19 17:54pm    
If the application is running locally and does not have its own security management system, then there is no way for the computer to know what that user should and should not be able to do. At some level, the user needs the appropriate permissions on the system to accomplish what is being done. Another option would be to run the 'application' as an API-based service and make calls to that API.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900