Connect to a different domain in AD

M

missoula

Hello-

I can connect to my own domain fine with the following:

entry = new DirectoryEntry("LDAP://RootDSE");

However, I am trying to get information out of AD for another domain.
This domain is trusted, but I can't seem to connect to it. This is
driving me crazy. Hard coding a DC name works, but I don't want to
hard code things in my code:

entry = VbecsWindowsUser.GetValidEntry("DC_Name");

I have tried all of the following:


DirectoryEntry entry = new DirectoryEntry("domainname",
@"domainname\userid", "Password", AuthenticationTypes.Secure);

entry = new DirectoryEntry("LDAP://domainname", @"domainname\userid",
"Password!", AuthenticationTypes.Secure);

entry = new DirectoryEntry("LDAP://DC=domainname",
@"domainname\userid", "Password!", AuthenticationTypes.Secure);

entry = new DirectoryEntry("DC=domainname", @"domainname\userid",
"Password!", AuthenticationTypes.Secure);

entry = new DirectoryEntry("LDAP://DC=domainname",
@"domainname\userid", "Password!", AuthenticationTypes.Secure);

entry = new DirectoryEntry("DC=domainname", @"domainname\userid",
"Password!", AuthenticationTypes.Secure);

entry = new DirectoryEntry("WinNT://DC=domainname",
@"domainname\userid", "Password!", AuthenticationTypes.Secure);

entry = new DirectoryEntry("WinNT://domainname", @"domainname\userid",
"Password!", AuthenticationTypes.Secure);

entry = new DirectoryEntry("WinNT://domainname", @"domainname\userid",
"Password!", AuthenticationTypes.Secure);

entry = new DirectoryEntry("DC=domainname", @"domainname\userid",
"Password!", AuthenticationTypes.Secure);

entry = new DirectoryEntry("domainname");

entry = new DirectoryEntry("LDAP://domain.com");

entry = new DirectoryEntry("LDAP://CN=domainname");

entry = new DirectoryEntry("LDAP://CN=domain.com");

entry = new
DirectoryEntry("LDAP://domain.com/CN=vha20jensec,CN=Users,DC=domain,DC=com");


entry = new DirectoryEntry("LDAP://DC=domain.com");

entry = new DirectoryEntry("LDAP://DC=domainname");

entry = new DirectoryEntry("WinNT://domainname");

entry = new DirectoryEntry("WinNT://domain.com");

Any help or suggestions would be much appreciated. Thanks!
 
V

Vadym Stetsyak

Here is one of the solutions

string _domain;
IPHostEntry ip = Dns.Resolve(_domain);
_domain = ip.HostName;

DirectoryEntry entry = new DirectoryEntry("LDAP://" + Domain);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top