?
Solved

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

Posted on 2008-06-12
6
Medium Priority
?
207 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
  • 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 1500 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
Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

 
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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

Compliance and data security require steps be taken to prevent unauthorized users from copying data.  Here's one method to prevent data theft via USB drives (and writable optical media).
In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
The viewer will learn how to dynamically set the form action using jQuery.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
Suggested Courses
Course of the Month13 days, 8 hours left to enroll

749 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