473,498 Members | 1,911 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Connect to a different domain in AD

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!

Nov 17 '05 #1
1 11773
Here is one of the solutions

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

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

--
Vadym Stetsyak aka Vadmyst
http://vadmyst.blogspot.com
<mi******@gmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
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!

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3270
by: Amadelle | last post by:
Hi all, I am so desparately in need of some guidance! After two days of struggling I still can't connect to the Active Directory server. I have used so many different ways and so many different...
7
2739
by: Reza | last post by:
Hello The project was working, where I had a domain user registered in the database as a user, and I used that user to connect the datebase. Everything was fine and it was working, then when I...
7
1492
by: Oenone | last post by:
Sorry for the cross-post but I've really no idea where this is best suited. I've an ADO.NET application which connects to a SQL Server database. I have spent the entire morning trying to get it...
5
4541
by: news.telia.net | last post by:
Hi! I have a question. I have installed php and mysql on an apache-server on windows and I can't connect to the server. I tried to create a database (since I am trying to learn howto). My...
1
2031
by: GNoter | last post by:
Scenario: I've a WebFarm with 2 web servers which are NLBs (network load balanced). Web1 and Web2; they are not part of a domain. I have a third server, Server3, which is part of a domain and on...
1
6878
by: Ben Hanson | last post by:
I've scoured Google searching for an answer that seems like it should be easy but apparently isn't...when I open SSMS to connect to a SQL 2005 database and choose Windows authentication, it greys...
0
1719
by: =?Utf-8?B?UHVjY2E=?= | last post by:
Hi, I'm using VS 2005, .net 2 and C# for a windows application. Let's say I'm running from loggin into a domain controller DC1. I have a treeview and nodes representing a DirectoryEntry object. ...
0
1405
by: Gunady | last post by:
Hi All, I have used ActiveX (written in C# 2.0) to render report and print it silently to printer. I have given up to use pure Javascript to do this. The code in ActiveX will connect to the...
3
6820
by: yawnmoth | last post by:
I'm trying to connect to an Active Directory server and am having some difficulties. Here's the code I'm using: <?php if (!($ldap = ldap_connect('domain.tld')) { exit('unable to connect'); }...
0
7125
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7002
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7165
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6885
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7379
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4588
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3093
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1417
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
290
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.