473,545 Members | 2,042 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Searching for Domain controllers when dinding using a dc name

Hello there
I need to get a list of domain controllers to a domain I bind too using it's
name rather than the DN.
I am trying a query looking for objectClass=nTD SDSA but this returns 0
results
I am using VB.net 2.0
any ideas?
Here's my code
Thanks in advance.

Dim entry As New DirectoryServic es.DirectoryEnt ry
entry.Path = "LDAP://" & TextBox1.Text
If RadioButton2.Ch ecked = False Then
entry.Username = TextBox3.Text
entry.Password = TextBox2.Text
End If
entry.Authentic ationType = DirectoryServic es.Authenticati onTypes.Secure
Dim searcher As New DirectoryServic es.DirectorySea rcher(entry)

Dim results As DirectoryServic es.SearchResult Collection
Dim result As DirectoryServic es.SearchResult
searcher.Search Scope = DirectoryServic es.SearchScope. Subtree
searcher.Filter = "(objectClass=n TDSDSA)"
results = (searcher.FindA ll())
Dim dcou As New DirectoryServic es.DirectoryEnt ry
For Each result In results
dcou = result.GetDirec toryEntry
MsgBox(dcou.Nam e)
Next
Dec 26 '05 #1
8 6250
Get the DNS name of the domain (use Translate to get the DN and convert the DC
part to a DNS name (i.e. remove the DC= and commas and put in the dots)) then
use DsGetDCOpen and the related functions.
--
Joe Richards Microsoft MVP Windows Server Directory Services
www.joeware.net
Sameh Ahmed wrote:
Hello there
I need to get a list of domain controllers to a domain I bind too using it's
name rather than the DN.
I am trying a query looking for objectClass=nTD SDSA but this returns 0
results
I am using VB.net 2.0
any ideas?
Here's my code
Thanks in advance.

Dim entry As New DirectoryServic es.DirectoryEnt ry
entry.Path = "LDAP://" & TextBox1.Text
If RadioButton2.Ch ecked = False Then
entry.Username = TextBox3.Text
entry.Password = TextBox2.Text
End If
entry.Authentic ationType = DirectoryServic es.Authenticati onTypes.Secure
Dim searcher As New DirectoryServic es.DirectorySea rcher(entry)

Dim results As DirectoryServic es.SearchResult Collection
Dim result As DirectoryServic es.SearchResult
searcher.Search Scope = DirectoryServic es.SearchScope. Subtree
searcher.Filter = "(objectClass=n TDSDSA)"
results = (searcher.FindA ll())
Dim dcou As New DirectoryServic es.DirectoryEnt ry
For Each result In results
dcou = result.GetDirec toryEntry
MsgBox(dcou.Nam e)
Next

Dec 27 '05 #2
In .NET 2.0, this is much easier with
System.Director yServices.Activ eDirectory. Just call the GetDomain static
method on the Domain class and enumerate the DomainControlle rs property. It
does all the locator service stuff for you under the hood.

Joe K.

"Sameh Ahmed" <es******@hotma il.com> wrote in message
news:Ov******** ********@tk2msf tngp13.phx.gbl. ..
Hello there
I need to get a list of domain controllers to a domain I bind too using
it's name rather than the DN.
I am trying a query looking for objectClass=nTD SDSA but this returns 0
results
I am using VB.net 2.0
any ideas?
Here's my code
Thanks in advance.

Dim entry As New DirectoryServic es.DirectoryEnt ry
entry.Path = "LDAP://" & TextBox1.Text
If RadioButton2.Ch ecked = False Then
entry.Username = TextBox3.Text
entry.Password = TextBox2.Text
End If
entry.Authentic ationType = DirectoryServic es.Authenticati onTypes.Secure
Dim searcher As New DirectoryServic es.DirectorySea rcher(entry)

Dim results As DirectoryServic es.SearchResult Collection
Dim result As DirectoryServic es.SearchResult
searcher.Search Scope = DirectoryServic es.SearchScope. Subtree
searcher.Filter = "(objectClass=n TDSDSA)"
results = (searcher.FindA ll())
Dim dcou As New DirectoryServic es.DirectoryEnt ry
For Each result In results
dcou = result.GetDirec toryEntry
MsgBox(dcou.Nam e)
Next

Dec 27 '05 #3
Thanks guys for the great help

"Joe Kaplan (MVP - ADSI)" <jo************ *@removethis.ac centure.com> wrote
in message news:OI******** ******@TK2MSFTN GP10.phx.gbl...
In .NET 2.0, this is much easier with
System.Director yServices.Activ eDirectory. Just call the GetDomain static
method on the Domain class and enumerate the DomainControlle rs property.
It does all the locator service stuff for you under the hood.

Joe K.

"Sameh Ahmed" <es******@hotma il.com> wrote in message
news:Ov******** ********@tk2msf tngp13.phx.gbl. ..
Hello there
I need to get a list of domain controllers to a domain I bind too using
it's name rather than the DN.
I am trying a query looking for objectClass=nTD SDSA but this returns 0
results
I am using VB.net 2.0
any ideas?
Here's my code
Thanks in advance.

Dim entry As New DirectoryServic es.DirectoryEnt ry
entry.Path = "LDAP://" & TextBox1.Text
If RadioButton2.Ch ecked = False Then
entry.Username = TextBox3.Text
entry.Password = TextBox2.Text
End If
entry.Authentic ationType = DirectoryServic es.Authenticati onTypes.Secure
Dim searcher As New DirectoryServic es.DirectorySea rcher(entry)

Dim results As DirectoryServic es.SearchResult Collection
Dim result As DirectoryServic es.SearchResult
searcher.Search Scope = DirectoryServic es.SearchScope. Subtree
searcher.Filter = "(objectClass=n TDSDSA)"
results = (searcher.FindA ll())
Dim dcou As New DirectoryServic es.DirectoryEnt ry
For Each result In results
dcou = result.GetDirec toryEntry
MsgBox(dcou.Nam e)
Next


Dec 30 '05 #4
Hello
getting the current domain is easy.
but how can I choose the domain to which I want to bind?
thanks in advance.

"Sameh Ahmed" <es******@hotma il.com> wrote in message
news:u1******** ******@TK2MSFTN GP15.phx.gbl...
Thanks guys for the great help

"Joe Kaplan (MVP - ADSI)" <jo************ *@removethis.ac centure.com> wrote
in message news:OI******** ******@TK2MSFTN GP10.phx.gbl...
In .NET 2.0, this is much easier with
System.Director yServices.Activ eDirectory. Just call the GetDomain static
method on the Domain class and enumerate the DomainControlle rs property.
It does all the locator service stuff for you under the hood.

Joe K.

"Sameh Ahmed" <es******@hotma il.com> wrote in message
news:Ov******** ********@tk2msf tngp13.phx.gbl. ..
Hello there
I need to get a list of domain controllers to a domain I bind too using
it's name rather than the DN.
I am trying a query looking for objectClass=nTD SDSA but this returns 0
results
I am using VB.net 2.0
any ideas?
Here's my code
Thanks in advance.

Dim entry As New DirectoryServic es.DirectoryEnt ry
entry.Path = "LDAP://" & TextBox1.Text
If RadioButton2.Ch ecked = False Then
entry.Username = TextBox3.Text
entry.Password = TextBox2.Text
End If
entry.Authentic ationType = DirectoryServic es.Authenticati onTypes.Secure
Dim searcher As New DirectoryServic es.DirectorySea rcher(entry)

Dim results As DirectoryServic es.SearchResult Collection
Dim result As DirectoryServic es.SearchResult
searcher.Search Scope = DirectoryServic es.SearchScope. Subtree
searcher.Filter = "(objectClass=n TDSDSA)"
results = (searcher.FindA ll())
Dim dcou As New DirectoryServic es.DirectoryEnt ry
For Each result In results
dcou = result.GetDirec toryEntry
MsgBox(dcou.Nam e)
Next



Jan 1 '06 #5
As I previously suggested, the GetDomain method allows you to specify a
domain.

Joe K.

"Sameh Ahmed" <es******@hotma il.com> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
Hello
getting the current domain is easy.
but how can I choose the domain to which I want to bind?
thanks in advance.

Jan 2 '06 #6
I know I sound really dumb
but I cannot get an example on contexts :(

"Joe Kaplan (MVP - ADSI)" <jo************ *@removethis.ac centure.com> wrote
in message news:Ob******** ******@TK2MSFTN GP11.phx.gbl...
As I previously suggested, the GetDomain method allows you to specify a
domain.

Joe K.

"Sameh Ahmed" <es******@hotma il.com> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
Hello
getting the current domain is easy.
but how can I choose the domain to which I want to bind?
thanks in advance.


Jan 4 '06 #7
np.

Domain d = Domain.GetDomai n(
new DirectoryContex t(
DirectoryContex tType.Domain,
"mydomain.c om")
);
foreach (DomainControll er dc in d.DomainControl lers)
{
Console.WriteLi ne(dc.ToString( ));
}

Joe K.

"Sameh Ahmed" <es******@hotma il.com> wrote in message
news:uN******** *****@TK2MSFTNG P14.phx.gbl...
I know I sound really dumb
but I cannot get an example on contexts :(

"Joe Kaplan (MVP - ADSI)" <jo************ *@removethis.ac centure.com> wrote
in message news:Ob******** ******@TK2MSFTN GP11.phx.gbl...
As I previously suggested, the GetDomain method allows you to specify a
domain.

Joe K.

"Sameh Ahmed" <es******@hotma il.com> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
Hello
getting the current domain is easy.
but how can I choose the domain to which I want to bind?
thanks in advance.



Jan 4 '06 #8
thanks a million

"Joe Kaplan (MVP - ADSI)" <jo************ *@removethis.ac centure.com> wrote
in message news:uP******** *****@TK2MSFTNG P12.phx.gbl...
np.

Domain d = Domain.GetDomai n(
new DirectoryContex t(
DirectoryContex tType.Domain,
"mydomain.c om")
);
foreach (DomainControll er dc in d.DomainControl lers)
{
Console.WriteLi ne(dc.ToString( ));
}

Joe K.

"Sameh Ahmed" <es******@hotma il.com> wrote in message
news:uN******** *****@TK2MSFTNG P14.phx.gbl...
I know I sound really dumb
but I cannot get an example on contexts :(

"Joe Kaplan (MVP - ADSI)" <jo************ *@removethis.ac centure.com>
wrote in message news:Ob******** ******@TK2MSFTN GP11.phx.gbl...
As I previously suggested, the GetDomain method allows you to specify a
domain.

Joe K.

"Sameh Ahmed" <es******@hotma il.com> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
Hello
getting the current domain is easy.
but how can I choose the domain to which I want to bind?
thanks in advance.



Jan 5 '06 #9

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

Similar topics

2
4795
by: Gerry | last post by:
I have a developer here with a website running with only "Windows Integrated Authentication" set on a Windows 2000 member server that uses GetObject to get a user's group membership in the domain. This is the code she's using: set adsUser = getobject("WinNT://" & strUsername) for each group in adsUser.groups GrpList = GrpList &...
1
1243
by: Pacher R. Dragos | last post by:
I have recently developed an application in c witch acts like a system logger for windows 2003 server domain controllers and my problem is that of the size. In a normal day my program produces more than 3-4 Mb of data in plain text, and you can imagine that interpreting or getting information from such a big file is time consuming, that's why...
3
4000
by: Prasad Karunakaran | last post by:
I have the following C# code to enumerate the list of groups in a domain using ADSI. The problem is if the domain contains machine accounts ($) it get those accounts too. Can somebody help me here to filter out the machine accounts so that I get only the NT group objects. public ArrayList GetNTGroups() { DirectoryEntry ntDirectoryGroups...
2
1975
by: Jordan | last post by:
Suppose I register a domain name, MyDomain.com, through register.com (or any other of the many domain name registrars). I own the domain name. The domain name goes into the global DNS database. As the facilitator in this process, exactly what does the registrar *own* with respect to my specific domain name and/or the registration process?...
0
1564
by: kanu | last post by:
Hi, We have moved our domain controllers from win2K to win3K. The script below doesnt work at all now because by default Win3K disables "Network access: Let Everyone permissions apply to anonymous users" GetObject("WinNT://domain/domainController/username,user") We are using GetObject to get the user groups, so as to restrict them to...
3
3272
by: Aaron | last post by:
I'm trying to parse a table on a webpage to pull down some data I need. The page is based off of information entered into a form. when you submit the data from the form it displays a "Searching..." page then, refreshes and displays the table I want. I have code that grabs data from the page using cURL but when I look at the data it contains...
3
2368
by: dkm234 | last post by:
I am trying to read Account Management category events of Security Logs using EventLog class, but I can not read the event message. Error message: "The description for Event ID '565' in Source 'Security' cannot be found. The local computer may not have the necessary registry information or message DLL files to display the message, or you may...
0
1079
by: =?Utf-8?B?U2FtZWVrc2hh?= | last post by:
Not sure which newsgroup this question should go to. I want to find out, using .net c# code whether a domain controller on the given machine is read only. The logic I am using is as follows - 1. Use System.Management namespace - ManagementObject and ObjectSearcher classes 2. First find out domain name for the given machine using...
0
875
by: Brian | last post by:
Hi, when connected to the network and using dns or enviorment i can find the Host name or domainname... but I would like to find all domains controls on a network and if possible list the ones that have a active directory .. but then if the domain controller can't be found.. get the local computer name. Kind of like the windows log in...
0
7478
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7668
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7923
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7437
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7773
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5343
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3466
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1901
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 we have to send another system
0
722
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.