I’m having trouble logging in to a specific OU in my ConsoleApp. I guess my LDAP string is incorrecct somehow, these are some output samples from my Test-App
This works fine
Path: LDAP://my.domain User: DOMAIN\user Pass: mypass
DOMAIN\user = Autenticated
But none of these
Path: LDAP://my.domain, ou=myou, dc=my, dc=domain User: user Pass: mypass
Path: LDAP://my.domain/ou=myou User: user Pass: mypass
Path: LDAP://my.domain/ou=myou User: DOMAIN\user Pass: mypass
They work in VBS though.. am I getting something all wrong or is it the AD guys that has to do something with my account? All I get is unknown user och wrong password.
They all work, if I leave out the “ou” part, conenctiong to my.domain is a breeze..
Regards
Your LDAP path should be something like:
(you need to provide the server name that you want to use as DC – as your Domain Controller)
or:
You cannot specify a username/password to use right in the LDAP string. If you need that, you’ll need to find another way to provide those credentials (like picking the right overloaded constructor for
DirectoryEntrywhich allows you to specify a username/password to use for connecting to AD).Update:
I think you should change your code to work like this:
I’m not sure if a LDAP string like this will work:
I vaguely remember I had to use a server name (not a domain name) to get this to work – something like this: