Home > Archive > Visual Basic Syntax > February 2005 > Script for enumerating users group info
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Script for enumerating users group info
|
|
| B Jose 2005-02-03, 4:02 pm |
| I'm looking for some assistance with a script. The script
requests a username, then displays the user's group
memberships along with each group's "Description". I've
been searching for a way to include the groups "Notes" (or
Info) field in the output. Is there a way to
include the Notes information within the script below?
Here's the script:
Dim DomainString
Dim UserObj
Dim GroupObj
Dim lstrUserName
Dim lbTrueFalse
DomainString = "mydomain.com"
lstrUserName = GetUserName
Set UserObj = GetObject("WinNT://" & DomainString & "/" &
lstrUserName)
wscript.echo "UserName: " & UserObj.Name
wscript.echo "Full Name: " & UserObj.FullName
wscript.echo "Description: " & UserObj.Description
wscript.echo "User is a member of:"
For Each GroupObj in UserObj.Groups
wscript.echo GroupObj.Name & " (" &
GroupObj.Comment & ")"
Next
Function GetUserName()
Dim tempUserName
set oArgs=wscript.arguments
If oArgs.Count <> 1 Then
tempUserName = InputBox ("Enter the Users
Logon Name:","User Info Inquiry")
If tempUserName = "" Then
WScript.Quit
End If
Else
tempUserName = oArgs.item(0)
End If
GetUserName = tempUserName
End Function
Thanks,
BJose
| |
| Jeff Johnson [MVP: VB] 2005-02-03, 4:02 pm |
|
"B Jose" <B Jose@discussions.microsoft.com> wrote in message
news:25AE1754-DB6E-4DE9-8916-A8421E11589B@microsoft.com...
> I'm looking for some assistance with a script.
microsoft.public.scripting.vbscript
| |
| Paul Clement 2005-02-03, 4:02 pm |
| On Thu, 3 Feb 2005 09:09:05 -0800, B Jose <B Jose@discussions.microsoft.com> wrote:
¤ I'm looking for some assistance with a script. The script
¤ requests a username, then displays the user's group
¤ memberships along with each group's "Description". I've
¤ been searching for a way to include the groups "Notes" (or
¤ Info) field in the output. Is there a way to
¤ include the Notes information within the script below?
¤
¤ Here's the script:
¤
¤ Dim DomainString
¤ Dim UserObj
¤ Dim GroupObj
¤ Dim lstrUserName
¤ Dim lbTrueFalse
¤
¤ DomainString = "mydomain.com"
¤
¤ lstrUserName = GetUserName
¤
¤ Set UserObj = GetObject("WinNT://" & DomainString & "/" &
¤ lstrUserName)
¤ wscript.echo "UserName: " & UserObj.Name
¤ wscript.echo "Full Name: " & UserObj.FullName
¤ wscript.echo "Description: " & UserObj.Description
¤
¤ wscript.echo "User is a member of:"
¤ For Each GroupObj in UserObj.Groups
¤ wscript.echo GroupObj.Name & " (" &
¤ GroupObj.Comment & ")"
¤
¤ Next
¤
¤
¤ Function GetUserName()
¤
¤ Dim tempUserName
¤
¤ set oArgs=wscript.arguments
¤
¤ If oArgs.Count <> 1 Then
¤ tempUserName = InputBox ("Enter the Users
¤ Logon Name:","User Info Inquiry")
¤ If tempUserName = "" Then
¤ WScript.Quit
¤ End If
¤ Else
¤ tempUserName = oArgs.item(0)
¤ End If
¤
¤ GetUserName = tempUserName
¤ End Function
I don't recognize the Group object property you mentioned (Notes). Have you tried using the Get
method to retrieve the value?
Paul ~~~ pclement@ameritech.net
Microsoft MVP (Visual Basic)
| |
|
| The group object property for the Notes field is "info"...
"Paul Clement" wrote:
> On Thu, 3 Feb 2005 09:09:05 -0800, B Jose <B Jose@discussions.microsoft.com> wrote:
>
> ¤ I'm looking for some assistance with a script. The script
> ¤ requests a username, then displays the user's group
> ¤ memberships along with each group's "Description". I've
> ¤ been searching for a way to include the groups "Notes" (or
> ¤ Info) field in the output. Is there a way to
> ¤ include the Notes information within the script below?
> ¤
> ¤ Here's the script:
> ¤
> ¤ Dim DomainString
> ¤ Dim UserObj
> ¤ Dim GroupObj
> ¤ Dim lstrUserName
> ¤ Dim lbTrueFalse
> ¤
> ¤ DomainString = "mydomain.com"
> ¤
> ¤ lstrUserName = GetUserName
> ¤
> ¤ Set UserObj = GetObject("WinNT://" & DomainString & "/" &
> ¤ lstrUserName)
> ¤ wscript.echo "UserName: " & UserObj.Name
> ¤ wscript.echo "Full Name: " & UserObj.FullName
> ¤ wscript.echo "Description: " & UserObj.Description
> ¤
> ¤ wscript.echo "User is a member of:"
> ¤ For Each GroupObj in UserObj.Groups
> ¤ wscript.echo GroupObj.Name & " (" &
> ¤ GroupObj.Comment & ")"
> ¤
> ¤ Next
> ¤
> ¤
> ¤ Function GetUserName()
> ¤
> ¤ Dim tempUserName
> ¤
> ¤ set oArgs=wscript.arguments
> ¤
> ¤ If oArgs.Count <> 1 Then
> ¤ tempUserName = InputBox ("Enter the Users
> ¤ Logon Name:","User Info Inquiry")
> ¤ If tempUserName = "" Then
> ¤ WScript.Quit
> ¤ End If
> ¤ Else
> ¤ tempUserName = oArgs.item(0)
> ¤ End If
> ¤
> ¤ GetUserName = tempUserName
> ¤ End Function
>
> I don't recognize the Group object property you mentioned (Notes). Have you tried using the Get
> method to retrieve the value?
>
>
> Paul ~~~ pclement@ameritech.net
> Microsoft MVP (Visual Basic)
>
| |
| Paul Clement 2005-02-04, 4:01 pm |
| On Thu, 3 Feb 2005 12:11:06 -0800, "BJose" <BJose@discussions.microsoft.com> wrote:
¤ The group object property for the Notes field is "info"...
¤
I took a closer look and found out these properties (Comment, Info) are not supported by the WinNT
provider. Since it appears your domain is Active Directory you will need to use the LDAP provider
instead. Here is an example which uses the authenticated user:
Set objSystemInfo = CreateObject("ADSystemInfo")
strAuthDistinguishedName = "LDAP://" & objSystemInfo.UserName
Set UserObj = GetObject(strAuthDistinguishedName)
wscript.echo "UserName: " & UserObj.Name
wscript.echo "Full Name: " & UserObj.FullName
wscript.echo "Description: " & UserObj.Description
wscript.echo "User is a member of:"
For Each GroupObj in UserObj.Groups
wscript.echo GroupObj.Name & " (" &
GroupObj.Comment & ")"
Paul ~~~ pclement@ameritech.net
Microsoft MVP (Visual Basic)
|
|
|
|
|