Note that there are some explanatory texts on larger screens.

plurals
  1. POHaving trouble binding to Active Directory with specified credentials
    text
    copied!<p>As part of my current role, I frequently find myself having to work with objects in one of my organisation's resource forests. At the moment in order to do that, I use an RDP session connected to a server within that forest, and authenticate to it with a specific "Admin" account in that forest.</p> <p>I'm starting to find this tedious, and so I've been trying to come up with a nice profile.ps1 which will get me a DirectoryEntry for the resource forest that I can work on with Powershell (v2.0) on my local workstation instead, and save me the tedium of constantly re-establishing RDP sessions.</p> <p>So I've got some code in my profile.ps1 which looks like this:</p> <pre><code>$resforest = "LDAP://DC=ldap,DC=path,DC=details" $creds = Get-Credential -credential "RESOURCE_FOREST\my_admin_account" $username = $creds.username $password = $creds.GetNetworkCredential().password $directoryentry = New-Object System.DirectoryServices.DirectoryEntry($resforest,$username,$password) </code></pre> <p>All of this proceeds fine, however, when I come to actually use the entry thus:</p> <pre><code>$search = New-Object DirectoryServices.DirectorySearcher($directoryentry) $search.filter = "(&amp;(anr=something_to_look_for))" $search.findall() </code></pre> <p>I get a logon failure.</p> <p>Now, I know the credentials are fine, I can map drives with them from my workstation to machines in the resource forest - and that works fine - so what am I ballsing up here?</p> <p>PS - Please don't ask me to do anything with Quest's AD cmdlets - they're not allowed here.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload