Problems with groups 
Author Message
 Problems with groups

I have been trying find the groups a user is associated with, a few people
have suggested this piece of code

strDomain="MACHINENAME"
strUser="jdoe"
Set oUser = GetObject("WinNT://" & strDomain & "/" & strUser)
set oGroups = oUser.Groups
For Each Group In oGroups
list = list & Group.Name
next
oUser=Nothing
oGroup=Nothing

I've tried it many times and it just does not work. What is the problem? I
am running
the script on a Windows NT4 workstation with Service Pack 3, ADSI 2, and WSH
installed. The workstation is running off an NT4 Server with SP3 installed
as
well. Can some one please tell me what I'm doing wrong.  I copied the
script and just substituted the domain and user names with my own. It ran
and nothing happend. It did not crash, it just exited. The oADSI object is
being created because if I add the line
msgbox oADIS.FullName
It comes back with the full name of the user, I just can't get at the
oADSI.groups attribute. This is quite frustrating.

Thanks for your help.

Dolan O'Toole



Fri, 09 Mar 2001 03:00:00 GMT  
 Problems with groups

Have you tried using the script de{*filter*} and stepping through each line of code?

place a line like this at the beginning of your script.

msgbox "Start debugging"

You also want to put a msgbox statement after each line of code. Your script should look like this when your done

msgbox "Start debugging"
strDomain="MACHINENAME"
msgbox strDomain
strUser="jdoe"
msgbox strUser
Set oUser = GetObject("WinNT://" & strDomain & "/" & strUser)
msgbox oUser.name
set oGroups = oUser.Groups
For Each Group In oGroups
list = list & Group.Name
msgbox list
next
oUser=Nothing
oGroup=Nothing

Launch your script and before you click "OK" Launch the script de{*filter*} and step through each line of code paying attention to what values are stored in the variables and how the script is behaving.

--
Check it out
http://www.*-*-*.com/

Win32 bit scripting, lots of sample scripts, downloads,
reference files, and technical support via an online discussion forum.

Quote:

>I have been trying find the groups a user is associated with, a few people
>have suggested this piece of code

>strDomain="MACHINENAME"
>strUser="jdoe"
>Set oUser = GetObject("WinNT://" & strDomain & "/" & strUser)
>set oGroups = oUser.Groups
>For Each Group In oGroups
>list = list & Group.Name
>next
>oUser=Nothing
>oGroup=Nothing

>I've tried it many times and it just does not work. What is the problem? I
>am running
>the script on a Windows NT4 workstation with Service Pack 3, ADSI 2, and WSH
>installed. The workstation is running off an NT4 Server with SP3 installed
>as
>well. Can some one please tell me what I'm doing wrong.  I copied the
>script and just substituted the domain and user names with my own. It ran
>and nothing happend. It did not crash, it just exited. The oADSI object is
>being created because if I add the line
>msgbox oADIS.FullName
>It comes back with the full name of the user, I just can't get at the
>oADSI.groups attribute. This is quite frustrating.

>Thanks for your help.

>Dolan O'Toole



Fri, 09 Mar 2001 03:00:00 GMT  
 Problems with groups
It works now!!! The only thing I can think that I was doing wrong was using
my PDC's name instead of my Domain's name in strDomain. Hmmmm...by machine
name, I thought you guys ment the actual server's name. That debuging tool
really helped, thanks Clarence. And thanks to every one who helped me out.

Dolan



Sun, 11 Mar 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. any active group to discuss Visual basic problems??

2. Login script problem - Trying to assign shortcuts via group ownership

3. nested group problem...

4. Problem getting list of groups user belongs to

5. Problem getting members of groups

6. Problems with ADSI and groups

7. Login script problem - Trying to assign shortcuts via group ownership

8. problem with Domain\Group registry entry

9. help Adding a Domain group to a Local Group

10. Enumerate users and groups that belong to a group

11. VB script: adding AD group to local administrators group

12. Adding multiple users or groups to local groups

 

 
Powered by phpBB® Forum Software