Search code examples
powershellactive-directorywindows-server

PowerShell error: Exception calling "FindOne" with "0" argument(s): "The user name or password is incorrect. "


There is a Windows Server VM in my department that hosts some of our Web Applications. We want one of this Web Applications to get, automatically, the user department based on his NT-USER. To do so, we imagine the following path:

  1. User enters in the Website. His NT-User is automatically taken by IIS Whindows Authentication;
  2. We Powershell (using an Active Directory API) using the NT-User as a parameter;
  3. We finally get the user name and department.

This API works fine in my personal computer, but not in the Server. I am executing a Powershell script like this:

$helpstring = find-user 'fie7ca' | select displayname, name, st, l, distinguishedname
$helpstring;

In my personal computer:

It works fine.

But then (in the Server), I receive the following error:

Exception calling "FindOne" with "0" argument(s): "The user name or password is incorrect.
"
At C:\Users\RBAdmin_App2\Documents\WindowsPowerShell\Modules\BC-Tools\User-Functions.psm1:496 char:11
+           $user = $searcher.FindOne()
+           ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DirectoryServicesCOMException

I am imagine that I need a Active Directory feature, use LDAP or something that I do not know.


Solution

  • This problem was regarding the company proxy.