Hi,

I need to retrived the office location for all the users in AD. Does anyone
has a vb script for this job?

Thanks,

--
Michelle

Re: Retrive office location by JHP

JHP
Tue Jun 21 14:52:15 CDT 2005

This is one way... depending on what version of Office your running and what
you have loaded:

Option Explicit
On Error Resume Next

Dim WSHShell, rtnValue

Set WSHShell = WScript.CreateObject("WScript.Shell")
rtnValue =
WSHShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\10.0\Word\InstallRoot\Path")
MsgBox(rtnValue)
Set WSHShell = Nothing

HTH

"Michelle Yu" <MichelleYu@discussions.microsoft.com> wrote in message
news:E2FF91CA-9B70-48A2-BEEA-ED8FA8E3AA6E@microsoft.com...
> Hi,
>
> I need to retrived the office location for all the users in AD. Does
> anyone
> has a vb script for this job?
>
> Thanks,
>
> --
> Michelle



Re: Retrive office location by JHP

JHP
Tue Jun 21 14:53:59 CDT 2005

Just re-reading your question and your probably asking for there working
office location not there software location... sorry!

"Michelle Yu" <MichelleYu@discussions.microsoft.com> wrote in message
news:E2FF91CA-9B70-48A2-BEEA-ED8FA8E3AA6E@microsoft.com...
> Hi,
>
> I need to retrived the office location for all the users in AD. Does
> anyone
> has a vb script for this job?
>
> Thanks,
>
> --
> Michelle



Re: Retrive office location by Richard

Richard
Tue Jun 21 16:02:10 CDT 2005

Michelle Yu wrote:

> I need to retrived the office location for all the users in AD. Does
anyone
> has a vb script for this job?

Hi,

You want the value of the physicalDeliveryOfficeName attribute for all
users. You can use ADO to retrieve this. Here is a link to an example
VBScript program to retrieve the Distinguished Name's of all users:

http://www.rlmueller.net/Create%20User%20List%202.htm

This program can be revised to also retrieve office location. First, add the
physicalDeliveryOfficeName attribute to the comma delimited list of
attribute values to be retrieved:

strFilter = "(&(objectCategory=person)(objectClass=user))"
strQuery = "<LDAP://" & strDNSDomain & ">;" & strFilter _
& ";distinguishedName,physicalDeliveryOfficeName;subtree"

Then, in the loop that enumerates the recordset returned by ADO, retrieve
the value and write it out with Distinguished Name:

' Declare new variable strOffice.
Dim strOffice
' Enumerate all users. Write each user's Distinguished Name to the file.
Set objRecordSet = objCommand.Execute
Do Until objRecordSet.EOF
strDN = objRecordSet.Fields("distinguishedName")
strOffice = objRecordset.Fields("physicalDeliveryOfficeName")
objFile.WriteLine strDN & ";" & strOffice
objRecordSet.MoveNext
Loop

I separated the DN and office location with a semicolon, because DN's have
commas. For more info on using ADO to retrieve information from AD:

http://www.rlmueller.net/ADOSearchTips.htm

--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab web site - http://www.rlmueller.net
--