Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 04-29-2008, 09:30 AM   #1 (permalink)
CntdwnToExtn's Avatar
 
Monster Techie

Join Date: Jan 2005

Location: Parents Basement

Posts: 1,340

CntdwnToExtn is on a distinguished road

Send a message via MSN to CntdwnToExtn
Default VBScript for A.D. Help

i have this script to display what groups each "user" belongs to in a specific OU

Code:
On Error Resume Next

Const E_ADS_PROPERTY_NOT_FOUND  = &h8000500D

Set objOU = GetObject _ 
	("LDAP://cn=users,dc=MyDomain,dc=com")
  
ObjOU.Filter = Array("user")
 
For Each objUser in objOU
    WScript.Echo objUser.cn & " is a member of: " 
    WScript.Echo vbTab & "Primary Group ID: " & _
        objUser.Get("primaryGroupID")
  
    arrMemberOf = objUser.GetEx("memberOf")
  
    If Err.Number <>  E_ADS_PROPERTY_NOT_FOUND Then
        For Each Group in arrMemberOf
            WScript.Echo vbTab & Group
        Next
    Else
        WScript.Echo vbTab & "memberOf attribute is not set"
        Err.Clear
    End If
    Wscript.Echo 
Next
which successfully finds all the users in the "Users" OU

however, i want it to find users in a different OU

i specifiy
Code:
Set objOU = GetObject _
("LDAP://cn=Different OU,dc=MyDomain,dc=com")
however the results turn up blank when i know there are users.

am i missing something here?
not all that familiar with VBS.

thanks
__________________
CntdwnToExtn is offline  
Old 04-29-2008, 09:44 AM   #2 (permalink)
Mak213's Avatar
 

Join Date: Sep 2004

Location: C:\Windows\System32

Posts: 25,667

Mak213 is a name known to allMak213 is a name known to allMak213 is a name known to allMak213 is a name known to allMak213 is a name known to allMak213 is a name known to all

Default Re: VBScript for A.D. Help

Wrong forum?? I dont think this should be in the Windows area.
__________________
R.I.P. Danny L. Trotter
14 Nov 1945 - 4 Sept 2009
Images created by CarnageX | Decaptured...Listen! | Visit Baezware!! | You've been Mak'd! | 儿做好
I do not accept support questions via EMail, PM, IM or my Spaces page! .:|:. This is what happens when an unstoppable force meets an immovable object.
Thanks to all the guys on the staff for your support in my time of need. Hefe you are my personal Hero for your contribution.



<<<< If I help you, or you just like what I said, rep me
Mak213 is offline  
Old 04-29-2008, 09:50 AM   #3 (permalink)
CntdwnToExtn's Avatar
 
Monster Techie

Join Date: Jan 2005

Location: Parents Basement

Posts: 1,340

CntdwnToExtn is on a distinguished road

Send a message via MSN to CntdwnToExtn
Default Re: VBScript for A.D. Help

my bad.
it was a toss up between windows - active directory help, or scripting
__________________
CntdwnToExtn is offline  
Old 04-29-2008, 08:08 PM   #4 (permalink)
 
Monster Techie

Join Date: May 2004

Location: /usr/root/mn/us

Posts: 1,121

bla!! is on a distinguished road

Default Re: VBScript for A.D. Help

What you want to specify in this section depends on your AD structure

Code:
("LDAP://cn=users,dc=MyDomain,dc=com")
Looking at your AD tree, it works from the inner-most OU out in your AD structure, left to right in your LDAP query.
For example, you want to target SubSubOU1 in the following example located here.

Code:
MyDomain.com
    OU1
    OU2
    OU3
        SubOU1
        SubOU2
             SubSubOu1
   OU4
The code for this would be
Code:
("LDAP://cn=SubSubOU1,cn=SubOU2,cn=OU3,dc=MyDomain,dc=com")
Does that make sense a bit?
__________________
<br>
Its a frigging Laptop, not a Labtop!!!!
bla!! is offline  
Old 04-29-2008, 11:36 PM   #5 (permalink)
Mak213's Avatar
 

Join Date: Sep 2004

Location: C:\Windows\System32

Posts: 25,667

Mak213 is a name known to allMak213 is a name known to allMak213 is a name known to allMak213 is a name known to allMak213 is a name known to allMak213 is a name known to all

Default Re: VBScript for A.D. Help

Quote:
Originally Posted by CntdwnToExtn View Post
my bad.
it was a toss up between windows - active directory help, or scripting
No problem. I jsut didnt think it would fit in with Windows as it requires coding.
__________________
R.I.P. Danny L. Trotter
14 Nov 1945 - 4 Sept 2009
Images created by CarnageX | Decaptured...Listen! | Visit Baezware!! | You've been Mak'd! | 儿做好
I do not accept support questions via EMail, PM, IM or my Spaces page! .:|:. This is what happens when an unstoppable force meets an immovable object.
Thanks to all the guys on the staff for your support in my time of need. Hefe you are my personal Hero for your contribution.



<<<< If I help you, or you just like what I said, rep me
Mak213 is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On