473,378 Members | 1,541 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

How to bind to DC depending on site

I'm trying to bind to DC by site. The environment is a AD 2K3 domain with
multiple sites.

For example, when my application is started, it checks for the site of the
computer where the application is running. Then, it looks for a DC in the
site and then all DirectorySearcher and DIrectoryEntry operations will use a
binding string aimed at that DC on the site.

If the DC is not available, then a default server, the PDC emulator is used.

How would I code in VB .Net the following:

1) Determine which site the current PC running my application is in.
2) Determine which domain controllers are in the site.
3) Bind directly to the domain controller on the site using
DirectoryServices.DirectoryEntry or DirectoryServices.DirectorySearcher

It's just that I don't trust the automatic DC selection when performing
directory operations.
Nov 20 '05 #1
3 1784
NC,
Why don't you trust "automatic DC selection"? When a user initializes a
logon, a DC in his/her site should answer the request and allow them access;
that DC's name will be stored in the %LOGONSERVER% variable. Any subsequent
request should go to this DC first, which is what you want to do, right?
Jared
"Net Coder" <ne***************@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
I'm trying to bind to DC by site. The environment is a AD 2K3 domain with
multiple sites.

For example, when my application is started, it checks for the site of the
computer where the application is running. Then, it looks for a DC in the
site and then all DirectorySearcher and DIrectoryEntry operations will use
a binding string aimed at that DC on the site.

If the DC is not available, then a default server, the PDC emulator is
used.

How would I code in VB .Net the following:

1) Determine which site the current PC running my application is in.
2) Determine which domain controllers are in the site.
3) Bind directly to the domain controller on the site using
DirectoryServices.DirectoryEntry or DirectoryServices.DirectorySearcher

It's just that I don't trust the automatic DC selection when performing
directory operations.

Nov 20 '05 #2


Jared wrote:
NC,
Why don't you trust "automatic DC selection"? When a user initializes a
logon, a DC in his/her site should answer the request and allow them access;
that DC's name will be stored in the %LOGONSERVER% variable. Any subsequent
request should go to this DC first, which is what you want to do, right?
Jared


Well, yes I want to bind to a DC on the site and have it guaranteed that I
always use the DC on the site for all AD queries. You see, my application
creates user accounts and then uses the information in the user account,
like the SID, immediately. With replication lag, and if the wrong DC on the
site is selected, the user account will not be on the DC which is being queried.

For example, if you create a user account on a DC and then try to create a
share immediately on another server and adjust the ACL on the share to
contain an ACE with the new user's SID, you might find that the lookup uses
a different DC on the site leading to the failure to create the share.
Nov 20 '05 #3
Net Coder wrote:
I'm trying to bind to DC by site. The environment is a AD 2K3 domain
with multiple sites.

For example, when my application is started, it checks for the site of
the computer where the application is running. Then, it looks for a DC
in the site and then all DirectorySearcher and DIrectoryEntry operations
will use a binding string aimed at that DC on the site.

If the DC is not available, then a default server, the PDC emulator is
used.

How would I code in VB .Net the following:

1) Determine which site the current PC running my application is in.
2) Determine which domain controllers are in the site.
3) Bind directly to the domain controller on the site using
DirectoryServices.DirectoryEntry or DirectoryServices.DirectorySearcher

It's just that I don't trust the automatic DC selection when performing
directory operations.

Hi

Step 1) and 2) with a vbscript:
'--------------------8<----------------------

' Get sitename of current computer
sSiteName = CreateObject("ADSystemInfo").SiteName

' Find domain controller in this site
Set oRootDSE = GetObject("LDAP://RootDSE")
Set oSubnetsCont = _
GetObject("LDAP://cn=Servers,cn=" & sSiteName & ",cn=sites," _
& oRootDSE.Get("configurationNamingContext") )

oSubnetsCont.Filter = Array("server")
sServerName = "" ' Init value
For Each oSubnet In oSubnetsCont
sServerName = oSubnet.Get("cn")
Exit For ' exit loop after first find
Next

If sServerName = "" Then
WScript.Echo "No server is defined in this site"
Else
WScript.Echo "Server defined in this site: " & sServerName
End If
'--------------------8<----------------------
--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scr...r/default.mspx
Nov 20 '05 #4

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

Similar topics

1
by: Daniel | last post by:
Hi, All! I have a problem - I manage two websites, with two different style sheets (one for each site), but they both share hte same public message boards and I want to change the CSS used by...
0
by: Steve | last post by:
Hi I have a db with 2 tables that I want to bind to a grid depending on a selection in a Dropdownlist Also I want to be able to select a row from the gris to fill some textboxes. The databases...
1
by: Bob | last post by:
Is there a way to bind an XmlDocument object (or XmlNodeList) directly to a DropDownList in the code behind? I know it can probably be done using DataBinder to specify the items in the aspx but I...
0
by: mike | last post by:
At this site, they use DB2 8.2.2 on LUW , and have thousands of DARI style stored procedures ('c', embedded-static SQL). During PREP and BIND they specify the package-owner with the OWNER...
14
by: DaTurk | last post by:
I am makeing a Multicast server client setup and was wondering what the difference is between Socket.Connect, and Socket.Bind. It may be a stupid question, but I was just curious. Because I...
2
by: sanju | last post by:
Hi, I am struggling to replace a bit value 'True' or 'False' with a image true.gif or false.gif and bind it to a repeater control. I am getting values 'true' or 'false' depending on whether...
3
by: weird0 | last post by:
Purpose: The objective is to update or add a new row in datagridview using an arraylist I have an arraylist inside of a class and i added an object to the arraylist on the button click event....
1
by: adolph | last post by:
I wrote an access2000 database for a POS system. In it is a sales form with a a subform showing the items being purchased. The main form is unbound. It uses a class to hold the main form data...
2
by: Dave | last post by:
ilee@bigpond.net.au (Ivan) wrote in message news:<90137e1b.0403301523.55aed707@posting.google.com>... Ivan - I little more specific to the java syntax. Right now you are probably using an...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.