Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Full LDAP path?

0 views
Skip to first unread message

Jason Rosolowski

unread,
Oct 27, 2004, 4:18:08 PM10/27/04
to
Here's what I'm trying to do.....

I want to write a script that will search for the user in the Active
Directory, enumerate their group membership, then map printers (and maybe
network drives in the future) based on group membership. There's the
overall picture of it.

Using code snippets from the Script Center and various other places, I was
able to do most of what I needed to do. I'm able to enumerate group
membership by somewhat "hardcoding" the LDAP path. I'm able to do this:

Set objUser = GetObject ("LDAP://CN=" & UCase(RTrim(objNetwork.UserName)) &
",OU=Corporate,OU=NHS Users,DC=northporthealth,DC=com")

What I need to do is change the part in there where it's "OU=Corporate" to
possibly "OU=Facility", depending on the user. So what I'd like to do if
possible, is FIND where that user is in the AD. Possible?

Or.....think of this. Would I need to check one OU and then the other OU
for that user?

One other thing I'd like to say too....If anyone knows of a script already
written for what I'm trying to do (assign printers based on group
membership), or one similar, please let me know.

Thanks!

--
Jason Rosolowski
Systems Administrator
Northport Health Services


Michael Harris (MVP)

unread,
Oct 27, 2004, 9:19:54 PM10/27/04
to
> ... So

> what I'd like to do if possible, is FIND where that user is in the
> AD. Possible?
>

set o = createobject("adsysteminfo")
wscript.echo o.username

Displays the full ldap path for the user. Use that to get a user object and
then get it's parent (object) property which should be the OU.

--
Michael Harris
Microsoft.MVP.Scripting
Sammamish WA US

Torgeir Bakken (MVP)

unread,
Oct 28, 2004, 3:00:14 AM10/28/04
to
Jason Rosolowski wrote:

> One other thing I'd like to say too....If anyone knows of a script already
> written for what I'm trying to do (assign printers based on group
> membership), or one similar, please let me know.

Hi

For some VBScript examples, take a look under "Group Membership Tests"
and "Logon Scripts" under "Free VBScript Code" at
http://www.rlmueller.net/

You will also find logon script examples with group testing etc. at
http://cwashington.netreach.net as well.

E.g. here:
http://cwashington.netreach.net/depo/default.asp?topic=repository&ScriptType=vbscript&SubType=LogonScripts


Some more general logon script links:

Frequently Asked Questions about Logon Scripts
http://www.rlmueller.net/LogonScriptFAQ.htm

Logon Script info at LabMice.net
http://labmice.techtarget.com/scripting/logonscripts.htm

Enterprise Logon Scripts
http://www.microsoft.com/downloads/details.aspx?familyid=3533b6bb-7ac7-4f42-825f-b122474d9a89&displaylang=en

--
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/scriptcenter/default.mspx

Jason Rosolowski

unread,
Oct 28, 2004, 10:42:45 AM10/28/04
to
Awesome, looks like this is going to work perfectly.

Thanks!

"Michael Harris (MVP)" <mikhar at mvps dot org> wrote in message
news:e48j8wIv...@TK2MSFTNGP14.phx.gbl...

0 new messages