Link to home
Start Free TrialLog in
Avatar of Bmich71
Bmich71

asked on

request help obtaining the site ou on local computers using either vba or CLI interface

in multiple site domain, I need to write a login script that will identify the AD site ou that is assigned to the computer the user is signing in on.
Avatar of geedoubleu
geedoubleu
Flag of United Kingdom of Great Britain and Northern Ireland image

If you are familiar with querying AD using VBScript you can grab the Users Distingusihed Name and then use Text functions to get the users OU.

Basically you search AD for the Users Logon name, create a User Object then query the user object for its distinguished name. The you can apply the spit function using , as the seperator to build an Array.
Avatar of Bmich71
Bmich71

ASKER

I have this;
Sub Determine_Site
  Set oADsSysInfo = CreateObject("ADSystemInfo")
  SITE = oADsSysInfo.SiteName
  Set oADsSysInfo = Nothing
End Sub

but it is not working.
ASKER CERTIFIED SOLUTION
Avatar of geedoubleu
geedoubleu
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Your code looks vaild, so there must be some other problem.

I'd look at your code that is using the variable SITE, I reckon there is a problem there.
Avatar of RobSampson
Hi, I have tested this:
  Set oADsSysInfo = CreateObject("ADSystemInfo")
  SITE = oADsSysInfo.SiteName
  Set oADsSysInfo = Nothing
  MsgBox SITE

and it returns the correct site...

Rob.
Avatar of Bmich71

ASKER

Actually the answer I got, was correct for the question I possed, but it turns out the question I possed was in the wrong area to find the solution to my problem.  Thanks.