Solved

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

Posted on 2008-06-12
6
197 Views
Last Modified: 2012-05-05
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.
0
Comment
Question by:Bmich71
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 2

Expert Comment

by:geedoubleu
ID: 21772207
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.
0
 

Author Comment

by:Bmich71
ID: 21772267
I have this;
Sub Determine_Site
  Set oADsSysInfo = CreateObject("ADSystemInfo")
  SITE = oADsSysInfo.SiteName
  Set oADsSysInfo = Nothing
End Sub

but it is not working.
0
 
LVL 2

Accepted Solution

by:
geedoubleu earned 500 total points
ID: 21772271
This should get you started...
Set objADInfo = WScript.CreateObject("ADSystemInfo")
strSite = objADInfo.SiteName
strUserDN = objADInfo.UserName
WScript.Echo strSite
WScript.Echo strUserDN

Open in new window

0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 2

Expert Comment

by:geedoubleu
ID: 21772292
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.
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 21775024
Hi, I have tested this:
  Set oADsSysInfo = CreateObject("ADSystemInfo")
  SITE = oADsSysInfo.SiteName
  Set oADsSysInfo = Nothing
  MsgBox SITE

and it returns the correct site...

Rob.
0
 

Author Closing Comment

by:Bmich71
ID: 31469975
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.
0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article outlines the process to identify and resolve account lockout in an Active Directory environment.
Always backup Domain, SYSVOL etc.using processes according to Microsoft Best Practices. This is meant as a disaster recovery process for small environments that did not implement backup processes and did not run a secondary domain controller that ne…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question