PC Review


Reply
Thread Tools Rate Thread

How to bind to DC depending on site

 
 
Net Coder
Guest
Posts: n/a
 
      25th Jul 2004
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.
 
Reply With Quote
 
 
 
 
Jared
Guest
Posts: n/a
 
      25th Jul 2004
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" <netcoder77-(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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.



 
Reply With Quote
 
Net Coder
Guest
Posts: n/a
 
      28th Jul 2004


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.
 
Reply With Quote
 
Torgeir Bakken \(MVP\)
Guest
Posts: n/a
 
      28th Jul 2004
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
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Web site view is different depending on monitor it is viewed on =?Utf-8?B?V2lzaCBMaXN0IFNlcnZpY2Vz?= Microsoft Frontpage 15 7th Feb 2007 08:13 PM
can change music depending on the data in my site? FireBrick Microsoft Frontpage 2 4th May 2005 08:22 PM
DataGrid Bind to DataSet, then Bind to DaTaview, GOT ERROR...PLS HELP A_PK Microsoft Dot NET Compact Framework 16 13th Apr 2005 04:27 AM
DataGrid Bind to DataSet, then Bind to DaTaview, GOT ERROR...PLS HELP A_PK Microsoft VB .NET 17 13th Apr 2005 04:27 AM
How to bind to DC depending on site Net Coder Microsoft VB .NET 3 28th Jul 2004 05:42 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:48 AM.