Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - WinNT error message

Reply
 
Old 09-16-2009   #1 (permalink)
kane9522


 
 

WinNT error message

Hi All, I am having some trouble with a script I am trying to write, I am
getting this error message:

Error: The Group name could not be found
Code: 800708AC
Source: (null)

what I am trying to do is determine whether a computer account in AD is part
of global group, I have code to do the same thing with user accounts, and the
user accounts code is working...the code for checking the computer is just a
copy of the user checking code...I have tested the user code and know that it
works, so one would assume that the computer checking code would also
work...any help would be appreciated...

Dim WshShell, WshEnv, objFSO, WshNetwork, objGroupListUser,
objGroupListComputer, objUserMemberOf, objGroupUser, objComputerMemberOf,
objGroupComputer
Dim objSysInfoUser, objSysInfoComputer, objDomain, objCurrentUser, UserObj,
objCurrentComputer, ComputerObj, objUser, objComputer
Dim DomainString, UserString, ComputerString, strUser, strComputer

Const OverwriteExisting = True

'On Error Resume Next

'Configures Variables
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshEnv = WshShell.Environment("Process")
Set WshNetwork = CreateObject("WScript.Network")

Set objSysInfoUser = CreateObject("ADSystemInfo")
Set objSysInfoComputer = CreateObject("ADSystemInfo")
Set objDomain = getObject("LDAP://rootDse")
DomainString = objDomain.Get("dnsHostName")

'Get user name
UserString = WshNetwork.UserName
Set objCurrentUser = GetObject("LDAP://" & objSysInfoUser.UserName)
Set UserObj = GetObject("WinNT://" & DomainString & "/" & UserString)
strUser = objSysInfoUser.UserName
Set objUser = GetObject("LDAP://" & strUser)

'Get Computer name
ComputerString = WshNetwork.ComputerName
Set objCurrentComputer = GetObject("LDAP://" &
objSysInfoComputer.ComputerName)

'This is the line that causes the error
Set ComputerObj = GetObject("WinNT://" & DomainString & "/" & ComputerString)

'Set ComputerObj = GetObject("WinNT://" & ComputerString)
strComputer = objSysInfoComputer.ComputerName
Set objComputer = GetObject("LDAP://" & strComputer)



objUserMemberOf = objUser.GetEx("memberOf")
For Each objGroupUser in objUserMemberOf
strListUser = strListUser & objGroupUser & vbcr
Next

'errors if computer has no groups...
'objComputerMemberOf = objComputer.GetEx("memberOf")
'For Each objGroupComputer in objComputerMemberOf
' strListComputer = strListComputer & objGroupComputer & vbcr
'Next

strFullName = objUser.FullName
strFirstName = objUser.FirstName



wscript.echo "Domain: " & DomainString
wscript.echo "Computer Network: " & ComputerString
wscript.echo "Computer ADInfo: " & strComputer
'wscript.echo "Full Name " & strFullName
'wscript.echo "First Name " & strFirstName
'wscript.echo "strUser " & strUser
'wscript.echo "Username " & UserString
WScript.Echo "Groups for " & strUser & vbCr & strListUser
wscript.echo "Groups for " & strComputer & vbCr & strListComputer


strGroupUser = "2003GG_NoPrintersConfig"
If (IsMemberUser(strGroupUser) = True) Then
Wscript.Echo "User " & objUser.name & " is a member of group " &
strGroupUser
ElseIf (IsMemberUser(strGroupUser) = False) Then
Wscript.Echo "User " & objUser.name & " is NOT a member of group " &
strGroupUser
End If

strGroupComputer = "2003GG_NoPrintersConfig"
If (IsMemberComputer(strGroupComputer) = True) Then
wscript.echo "Computer " & objComputer.name & " is a member of group " &
strGroupComputer
ElseIf (IsMemberComputer(strGroupComputer) = False) Then
wscript.echo "Computer " & objComputer.name & " is not a member of group "
& strGroupComputer
End If

Function IsMemberUser(ByVal strGroupUser)

' Function to test for group membership.
' strGroup is the NT name (sAMAccountName) of the group to test.
' objGroupList is a dictionary object, with global scope.
' Returns True if the user or computer is a member of the group.

If (IsEmpty(objGroupListUser) = True) Then
Set objGroupListUser = CreateObject("Scripting.Dictionary")
Call LoadGroupsUser(objUser)
End If

IsMemberUser = objGroupListUser.Exists(strGroupUser)

End Function

Function IsMemberComputer(ByVal strGroupComputer)

' Function to test for group membership.
' strGroup is the NT name (sAMAccountName) of the group to test.
' objGroupList is a dictionary object, with global scope.
' Returns True if the user or computer is a member of the group.

If (IsEmpty(objGroupListComputer) = True) Then
Set objGroupListComputer = CreateObject("Scripting.Dictionary")
Call LoadGroupsComputer(objComputer)
End If

IsMemberComptuer = objGroupListComputer.Exists(strGroupComputer)

End Function

Sub LoadGroupsUser(ByVal objUser)

' Recursive subroutine to populate dictionary object with group
' memberships. When this subroutine is first called by Function
' IsMember, objADObject is the user or computer object. On recursive calls
' objADObject will be a group object. For each group in the MemberOf
' collection, first check to see if the group is already in the
' dictionary object. If it is not, add the group to the dictionary
' object and recursively call this subroutine again to enumerate any
' groups the group might be a member of (nested groups). It is necessary
' to first check if the group is already in the dictionary object to
' prevent an infinite loop if the group nesting is "circular".

Dim colstrGroups, objGroup, j

objGroupListUser.CompareMode = vbTextCompare

colstrGroups = objUser.memberOf

If (IsEmpty(colstrGroups) = True) Then
Exit Sub
End If

If (TypeName(colstrGroups) = "String") Then

' Escape any forward slash characters, "/", with the backslash
' escape character. All other characters that should be escaped are.

colstrGroups = Replace(colstrGroups, "/", "\/")

Set objGroup = GetObject("LDAP://" & colstrGroups)

If (objGroupListUser.Exists(objGroup.sAMAccountName) = False) Then
objGroupListUser.Add objGroup.sAMAccountName, True
Call LoadGroupsUser(objGroup)
End If

Set objGroup = Nothing

Exit Sub

End If

For j = 0 To UBound(colstrGroups)

' Escape any forward slash characters, "/", with the backslash
' escape character. All other characters that should be escaped are.

colstrGroups(j) = Replace(colstrGroups(j), "/", "\/")

Set objGroup = GetObject("LDAP://" & colstrGroups(j))

If (objGroupListUser.Exists(objGroup.sAMAccountName) = False) Then
objGroupListUser.Add objGroup.sAMAccountName, True
Call LoadGroupsUser(objGroup)
End If

Next

Set objGroup = Nothing

End Sub

Sub LoadGroupsComputer(ByVal objComputer)

' Recursive subroutine to populate dictionary object with group
' memberships. When this subroutine is first called by Function
' IsMember, objADObject is the user or computer object. On recursive calls
' objADObject will be a group object. For each group in the MemberOf
' collection, first check to see if the group is already in the
' dictionary object. If it is not, add the group to the dictionary
' object and recursively call this subroutine again to enumerate any
' groups the group might be a member of (nested groups). It is necessary
' to first check if the group is already in the dictionary object to
' prevent an infinite loop if the group nesting is "circular".

Dim colstrGroups, objGroup, j

objGroupListComputer.CompareMode = vbTextCompare

colstrGroups = objComputer.memberOf

If (IsEmpty(colstrGroups) = True) Then
Exit Sub
End If

If (TypeName(colstrGroups) = "String") Then

' Escape any forward slash characters, "/", with the backslash
' escape character. All other characters that should be escaped are.

colstrGroups = Replace(colstrGroups, "/", "\/")

Set objGroup = GetObject("LDAP://" & colstrGroups)

If (objGroupListComputer.Exists(objGroup.sAMAccountName) = False) Then
objGroupListComputer.Add objGroup.sAMAccountName, True
Call LoadGroupsComputer(objGroup)
End If

Set objGroup = Nothing

Exit Sub

End If

For j = 0 To UBound(colstrGroups)

' Escape any forward slash characters, "/", with the backslash
' escape character. All other characters that should be escaped are.

colstrGroups(j) = Replace(colstrGroups(j), "/", "\/")

Set objGroup = GetObject("LDAP://" & colstrGroups(j))

If (objGroupListComputer.Exists(objGroup.sAMAccountName) = False) Then
objGroupListComputer.Add objGroup.sAMAccountName, True
Call LoadGroupsComputer(objGroup)
End If

Next

Set objGroup = Nothing

End Sub

My System SpecsSystem Spec
Old 09-16-2009   #2 (permalink)
Richard Mueller [MVP]


 
 

Re: WinNT error message

First, there is probably no reason to use the WinNT provider. It is slower
and reveals fewer attributes. If you do use it, use wshNetwork.UserDomain to
retrieve the NetBIOS name of the domain. The value of RootDSE.dnsHostName
will be similar to:

MyComputer.MyDomain.com

where MyComputer is a Domain Controller.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--

"kane9522" <kane9522@newsgroup> wrote in message
news:45E24808-D861-44D9-964F-1F8EE0B59B6B@newsgroup
Quote:

> Hi All, I am having some trouble with a script I am trying to write, I am
> getting this error message:
>
> Error: The Group name could not be found
> Code: 800708AC
> Source: (null)
>
> what I am trying to do is determine whether a computer account in AD is
> part
> of global group, I have code to do the same thing with user accounts, and
> the
> user accounts code is working...the code for checking the computer is just
> a
> copy of the user checking code...I have tested the user code and know that
> it
> works, so one would assume that the computer checking code would also
> work...any help would be appreciated...
>
> Dim WshShell, WshEnv, objFSO, WshNetwork, objGroupListUser,
> objGroupListComputer, objUserMemberOf, objGroupUser, objComputerMemberOf,
> objGroupComputer
> Dim objSysInfoUser, objSysInfoComputer, objDomain, objCurrentUser,
> UserObj,
> objCurrentComputer, ComputerObj, objUser, objComputer
> Dim DomainString, UserString, ComputerString, strUser, strComputer
>
> Const OverwriteExisting = True
>
> 'On Error Resume Next
>
> 'Configures Variables
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> Set WshShell = WScript.CreateObject("WScript.Shell")
> Set WshEnv = WshShell.Environment("Process")
> Set WshNetwork = CreateObject("WScript.Network")
>
> Set objSysInfoUser = CreateObject("ADSystemInfo")
> Set objSysInfoComputer = CreateObject("ADSystemInfo")
> Set objDomain = getObject("LDAP://rootDse")
> DomainString = objDomain.Get("dnsHostName")
>
> 'Get user name
> UserString = WshNetwork.UserName
> Set objCurrentUser = GetObject("LDAP://" & objSysInfoUser.UserName)
> Set UserObj = GetObject("WinNT://" & DomainString & "/" & UserString)
> strUser = objSysInfoUser.UserName
> Set objUser = GetObject("LDAP://" & strUser)
>
> 'Get Computer name
> ComputerString = WshNetwork.ComputerName
> Set objCurrentComputer = GetObject("LDAP://" &
> objSysInfoComputer.ComputerName)
>
> 'This is the line that causes the error
> Set ComputerObj = GetObject("WinNT://" & DomainString & "/" &
> ComputerString)
>
> 'Set ComputerObj = GetObject("WinNT://" & ComputerString)
> strComputer = objSysInfoComputer.ComputerName
> Set objComputer = GetObject("LDAP://" & strComputer)
>
>
>
> objUserMemberOf = objUser.GetEx("memberOf")
> For Each objGroupUser in objUserMemberOf
> strListUser = strListUser & objGroupUser & vbcr
> Next
>
> 'errors if computer has no groups...
> 'objComputerMemberOf = objComputer.GetEx("memberOf")
> 'For Each objGroupComputer in objComputerMemberOf
> ' strListComputer = strListComputer & objGroupComputer & vbcr
> 'Next
>
> strFullName = objUser.FullName
> strFirstName = objUser.FirstName
>
>
>
> wscript.echo "Domain: " & DomainString
> wscript.echo "Computer Network: " & ComputerString
> wscript.echo "Computer ADInfo: " & strComputer
> 'wscript.echo "Full Name " & strFullName
> 'wscript.echo "First Name " & strFirstName
> 'wscript.echo "strUser " & strUser
> 'wscript.echo "Username " & UserString
> WScript.Echo "Groups for " & strUser & vbCr & strListUser
> wscript.echo "Groups for " & strComputer & vbCr & strListComputer
>
>
> strGroupUser = "2003GG_NoPrintersConfig"
> If (IsMemberUser(strGroupUser) = True) Then
> Wscript.Echo "User " & objUser.name & " is a member of group " &
> strGroupUser
> ElseIf (IsMemberUser(strGroupUser) = False) Then
> Wscript.Echo "User " & objUser.name & " is NOT a member of group " &
> strGroupUser
> End If
>
> strGroupComputer = "2003GG_NoPrintersConfig"
> If (IsMemberComputer(strGroupComputer) = True) Then
> wscript.echo "Computer " & objComputer.name & " is a member of group " &
> strGroupComputer
> ElseIf (IsMemberComputer(strGroupComputer) = False) Then
> wscript.echo "Computer " & objComputer.name & " is not a member of group "
> & strGroupComputer
> End If
>
> Function IsMemberUser(ByVal strGroupUser)
>
> ' Function to test for group membership.
> ' strGroup is the NT name (sAMAccountName) of the group to test.
> ' objGroupList is a dictionary object, with global scope.
> ' Returns True if the user or computer is a member of the group.
>
> If (IsEmpty(objGroupListUser) = True) Then
> Set objGroupListUser = CreateObject("Scripting.Dictionary")
> Call LoadGroupsUser(objUser)
> End If
>
> IsMemberUser = objGroupListUser.Exists(strGroupUser)
>
> End Function
>
> Function IsMemberComputer(ByVal strGroupComputer)
>
> ' Function to test for group membership.
> ' strGroup is the NT name (sAMAccountName) of the group to test.
> ' objGroupList is a dictionary object, with global scope.
> ' Returns True if the user or computer is a member of the group.
>
> If (IsEmpty(objGroupListComputer) = True) Then
> Set objGroupListComputer = CreateObject("Scripting.Dictionary")
> Call LoadGroupsComputer(objComputer)
> End If
>
> IsMemberComptuer = objGroupListComputer.Exists(strGroupComputer)
>
> End Function
>
> Sub LoadGroupsUser(ByVal objUser)
>
> ' Recursive subroutine to populate dictionary object with group
> ' memberships. When this subroutine is first called by Function
> ' IsMember, objADObject is the user or computer object. On recursive
> calls
> ' objADObject will be a group object. For each group in the MemberOf
> ' collection, first check to see if the group is already in the
> ' dictionary object. If it is not, add the group to the dictionary
> ' object and recursively call this subroutine again to enumerate any
> ' groups the group might be a member of (nested groups). It is
> necessary
> ' to first check if the group is already in the dictionary object to
> ' prevent an infinite loop if the group nesting is "circular".
>
> Dim colstrGroups, objGroup, j
>
> objGroupListUser.CompareMode = vbTextCompare
>
> colstrGroups = objUser.memberOf
>
> If (IsEmpty(colstrGroups) = True) Then
> Exit Sub
> End If
>
> If (TypeName(colstrGroups) = "String") Then
>
> ' Escape any forward slash characters, "/", with the backslash
> ' escape character. All other characters that should be escaped
> are.
>
> colstrGroups = Replace(colstrGroups, "/", "\/")
>
> Set objGroup = GetObject("LDAP://" & colstrGroups)
>
> If (objGroupListUser.Exists(objGroup.sAMAccountName) = False) Then
> objGroupListUser.Add objGroup.sAMAccountName, True
> Call LoadGroupsUser(objGroup)
> End If
>
> Set objGroup = Nothing
>
> Exit Sub
>
> End If
>
> For j = 0 To UBound(colstrGroups)
>
> ' Escape any forward slash characters, "/", with the backslash
> ' escape character. All other characters that should be escaped
> are.
>
> colstrGroups(j) = Replace(colstrGroups(j), "/", "\/")
>
> Set objGroup = GetObject("LDAP://" & colstrGroups(j))
>
> If (objGroupListUser.Exists(objGroup.sAMAccountName) = False) Then
> objGroupListUser.Add objGroup.sAMAccountName, True
> Call LoadGroupsUser(objGroup)
> End If
>
> Next
>
> Set objGroup = Nothing
>
> End Sub
>
> Sub LoadGroupsComputer(ByVal objComputer)
>
> ' Recursive subroutine to populate dictionary object with group
> ' memberships. When this subroutine is first called by Function
> ' IsMember, objADObject is the user or computer object. On recursive
> calls
> ' objADObject will be a group object. For each group in the MemberOf
> ' collection, first check to see if the group is already in the
> ' dictionary object. If it is not, add the group to the dictionary
> ' object and recursively call this subroutine again to enumerate any
> ' groups the group might be a member of (nested groups). It is
> necessary
> ' to first check if the group is already in the dictionary object to
> ' prevent an infinite loop if the group nesting is "circular".
>
> Dim colstrGroups, objGroup, j
>
> objGroupListComputer.CompareMode = vbTextCompare
>
> colstrGroups = objComputer.memberOf
>
> If (IsEmpty(colstrGroups) = True) Then
> Exit Sub
> End If
>
> If (TypeName(colstrGroups) = "String") Then
>
> ' Escape any forward slash characters, "/", with the backslash
> ' escape character. All other characters that should be escaped
> are.
>
> colstrGroups = Replace(colstrGroups, "/", "\/")
>
> Set objGroup = GetObject("LDAP://" & colstrGroups)
>
> If (objGroupListComputer.Exists(objGroup.sAMAccountName) = False)
> Then
> objGroupListComputer.Add objGroup.sAMAccountName, True
> Call LoadGroupsComputer(objGroup)
> End If
>
> Set objGroup = Nothing
>
> Exit Sub
>
> End If
>
> For j = 0 To UBound(colstrGroups)
>
> ' Escape any forward slash characters, "/", with the backslash
> ' escape character. All other characters that should be escaped
> are.
>
> colstrGroups(j) = Replace(colstrGroups(j), "/", "\/")
>
> Set objGroup = GetObject("LDAP://" & colstrGroups(j))
>
> If (objGroupListComputer.Exists(objGroup.sAMAccountName) = False)
> Then
> objGroupListComputer.Add objGroup.sAMAccountName, True
> Call LoadGroupsComputer(objGroup)
> End If
>
> Next
>
> Set objGroup = Nothing
>
> End Sub

My System SpecsSystem Spec
Old 09-16-2009   #3 (permalink)
kane9522


 
 

Re: WinNT error message

Hi Richard,
using that WshNetwork.UserDomain has fixed the error
message but is still not showing that the computer account is part of a
particular group...I can check AD and see that the computer account
definitely has the group I need to check it for, in this case
2003GG_NoPrintersConfig, the check works correctly for the user account...any
ideas??

"Richard Mueller [MVP]" wrote:
Quote:

> First, there is probably no reason to use the WinNT provider. It is slower
> and reveals fewer attributes. If you do use it, use wshNetwork.UserDomain to
> retrieve the NetBIOS name of the domain. The value of RootDSE.dnsHostName
> will be similar to:
>
> MyComputer.MyDomain.com
>
> where MyComputer is a Domain Controller.
>
> --
> Richard Mueller
> MVP Directory Services
> Hilltop Lab - http://www.rlmueller.net
> --
>
> "kane9522" <kane9522@newsgroup> wrote in message
> news:45E24808-D861-44D9-964F-1F8EE0B59B6B@newsgroup
Quote:

> > Hi All, I am having some trouble with a script I am trying to write, I am
> > getting this error message:
> >
> > Error: The Group name could not be found
> > Code: 800708AC
> > Source: (null)
> >
> > what I am trying to do is determine whether a computer account in AD is
> > part
> > of global group, I have code to do the same thing with user accounts, and
> > the
> > user accounts code is working...the code for checking the computer is just
> > a
> > copy of the user checking code...I have tested the user code and know that
> > it
> > works, so one would assume that the computer checking code would also
> > work...any help would be appreciated...
> >
> > Dim WshShell, WshEnv, objFSO, WshNetwork, objGroupListUser,
> > objGroupListComputer, objUserMemberOf, objGroupUser, objComputerMemberOf,
> > objGroupComputer
> > Dim objSysInfoUser, objSysInfoComputer, objDomain, objCurrentUser,
> > UserObj,
> > objCurrentComputer, ComputerObj, objUser, objComputer
> > Dim DomainString, UserString, ComputerString, strUser, strComputer
> >
> > Const OverwriteExisting = True
> >
> > 'On Error Resume Next
> >
> > 'Configures Variables
> > Set objFSO = CreateObject("Scripting.FileSystemObject")
> > Set WshShell = WScript.CreateObject("WScript.Shell")
> > Set WshEnv = WshShell.Environment("Process")
> > Set WshNetwork = CreateObject("WScript.Network")
> >
> > Set objSysInfoUser = CreateObject("ADSystemInfo")
> > Set objSysInfoComputer = CreateObject("ADSystemInfo")
> > Set objDomain = getObject("LDAP://rootDse")
> > DomainString = objDomain.Get("dnsHostName")
> >
> > 'Get user name
> > UserString = WshNetwork.UserName
> > Set objCurrentUser = GetObject("LDAP://" & objSysInfoUser.UserName)
> > Set UserObj = GetObject("WinNT://" & DomainString & "/" & UserString)
> > strUser = objSysInfoUser.UserName
> > Set objUser = GetObject("LDAP://" & strUser)
> >
> > 'Get Computer name
> > ComputerString = WshNetwork.ComputerName
> > Set objCurrentComputer = GetObject("LDAP://" &
> > objSysInfoComputer.ComputerName)
> >
> > 'This is the line that causes the error
> > Set ComputerObj = GetObject("WinNT://" & DomainString & "/" &
> > ComputerString)
> >
> > 'Set ComputerObj = GetObject("WinNT://" & ComputerString)
> > strComputer = objSysInfoComputer.ComputerName
> > Set objComputer = GetObject("LDAP://" & strComputer)
> >
> >
> >
> > objUserMemberOf = objUser.GetEx("memberOf")
> > For Each objGroupUser in objUserMemberOf
> > strListUser = strListUser & objGroupUser & vbcr
> > Next
> >
> > 'errors if computer has no groups...
> > 'objComputerMemberOf = objComputer.GetEx("memberOf")
> > 'For Each objGroupComputer in objComputerMemberOf
> > ' strListComputer = strListComputer & objGroupComputer & vbcr
> > 'Next
> >
> > strFullName = objUser.FullName
> > strFirstName = objUser.FirstName
> >
> >
> >
> > wscript.echo "Domain: " & DomainString
> > wscript.echo "Computer Network: " & ComputerString
> > wscript.echo "Computer ADInfo: " & strComputer
> > 'wscript.echo "Full Name " & strFullName
> > 'wscript.echo "First Name " & strFirstName
> > 'wscript.echo "strUser " & strUser
> > 'wscript.echo "Username " & UserString
> > WScript.Echo "Groups for " & strUser & vbCr & strListUser
> > wscript.echo "Groups for " & strComputer & vbCr & strListComputer
> >
> >
> > strGroupUser = "2003GG_NoPrintersConfig"
> > If (IsMemberUser(strGroupUser) = True) Then
> > Wscript.Echo "User " & objUser.name & " is a member of group " &
> > strGroupUser
> > ElseIf (IsMemberUser(strGroupUser) = False) Then
> > Wscript.Echo "User " & objUser.name & " is NOT a member of group " &
> > strGroupUser
> > End If
> >
> > strGroupComputer = "2003GG_NoPrintersConfig"
> > If (IsMemberComputer(strGroupComputer) = True) Then
> > wscript.echo "Computer " & objComputer.name & " is a member of group " &
> > strGroupComputer
> > ElseIf (IsMemberComputer(strGroupComputer) = False) Then
> > wscript.echo "Computer " & objComputer.name & " is not a member of group "
> > & strGroupComputer
> > End If
> >
> > Function IsMemberUser(ByVal strGroupUser)
> >
> > ' Function to test for group membership.
> > ' strGroup is the NT name (sAMAccountName) of the group to test.
> > ' objGroupList is a dictionary object, with global scope.
> > ' Returns True if the user or computer is a member of the group.
> >
> > If (IsEmpty(objGroupListUser) = True) Then
> > Set objGroupListUser = CreateObject("Scripting.Dictionary")
> > Call LoadGroupsUser(objUser)
> > End If
> >
> > IsMemberUser = objGroupListUser.Exists(strGroupUser)
> >
> > End Function
> >
> > Function IsMemberComputer(ByVal strGroupComputer)
> >
> > ' Function to test for group membership.
> > ' strGroup is the NT name (sAMAccountName) of the group to test.
> > ' objGroupList is a dictionary object, with global scope.
> > ' Returns True if the user or computer is a member of the group.
> >
> > If (IsEmpty(objGroupListComputer) = True) Then
> > Set objGroupListComputer = CreateObject("Scripting.Dictionary")
> > Call LoadGroupsComputer(objComputer)
> > End If
> >
> > IsMemberComptuer = objGroupListComputer.Exists(strGroupComputer)
> >
> > End Function
> >
> > Sub LoadGroupsUser(ByVal objUser)
> >
> > ' Recursive subroutine to populate dictionary object with group
> > ' memberships. When this subroutine is first called by Function
> > ' IsMember, objADObject is the user or computer object. On recursive
> > calls
> > ' objADObject will be a group object. For each group in the MemberOf
> > ' collection, first check to see if the group is already in the
> > ' dictionary object. If it is not, add the group to the dictionary
> > ' object and recursively call this subroutine again to enumerate any
> > ' groups the group might be a member of (nested groups). It is
> > necessary
> > ' to first check if the group is already in the dictionary object to
> > ' prevent an infinite loop if the group nesting is "circular".
> >
> > Dim colstrGroups, objGroup, j
> >
> > objGroupListUser.CompareMode = vbTextCompare
> >
> > colstrGroups = objUser.memberOf
> >
> > If (IsEmpty(colstrGroups) = True) Then
> > Exit Sub
> > End If
> >
> > If (TypeName(colstrGroups) = "String") Then
> >
> > ' Escape any forward slash characters, "/", with the backslash
> > ' escape character. All other characters that should be escaped
> > are.
> >
> > colstrGroups = Replace(colstrGroups, "/", "\/")
> >
> > Set objGroup = GetObject("LDAP://" & colstrGroups)
> >
> > If (objGroupListUser.Exists(objGroup.sAMAccountName) = False) Then
> > objGroupListUser.Add objGroup.sAMAccountName, True
> > Call LoadGroupsUser(objGroup)
> > End If
> >
> > Set objGroup = Nothing
> >
> > Exit Sub
> >
> > End If
> >
> > For j = 0 To UBound(colstrGroups)
> >
> > ' Escape any forward slash characters, "/", with the backslash
> > ' escape character. All other characters that should be escaped
> > are.
> >
> > colstrGroups(j) = Replace(colstrGroups(j), "/", "\/")
> >
> > Set objGroup = GetObject("LDAP://" & colstrGroups(j))
> >
> > If (objGroupListUser.Exists(objGroup.sAMAccountName) = False) Then
> > objGroupListUser.Add objGroup.sAMAccountName, True
> > Call LoadGroupsUser(objGroup)
> > End If
> >
> > Next
> >
> > Set objGroup = Nothing
> >
> > End Sub
> >
> > Sub LoadGroupsComputer(ByVal objComputer)
> >
> > ' Recursive subroutine to populate dictionary object with group
> > ' memberships. When this subroutine is first called by Function
> > ' IsMember, objADObject is the user or computer object. On recursive
> > calls
> > ' objADObject will be a group object. For each group in the MemberOf
> > ' collection, first check to see if the group is already in the
> > ' dictionary object. If it is not, add the group to the dictionary
> > ' object and recursively call this subroutine again to enumerate any
> > ' groups the group might be a member of (nested groups). It is
> > necessary
> > ' to first check if the group is already in the dictionary object to
> > ' prevent an infinite loop if the group nesting is "circular".
> >
> > Dim colstrGroups, objGroup, j
> >
> > objGroupListComputer.CompareMode = vbTextCompare
> >
> > colstrGroups = objComputer.memberOf
> >
> > If (IsEmpty(colstrGroups) = True) Then
> > Exit Sub
> > End If
> >
> > If (TypeName(colstrGroups) = "String") Then
> >
> > ' Escape any forward slash characters, "/", with the backslash
> > ' escape character. All other characters that should be escaped
> > are.
> >
> > colstrGroups = Replace(colstrGroups, "/", "\/")
> >
> > Set objGroup = GetObject("LDAP://" & colstrGroups)
> >
> > If (objGroupListComputer.Exists(objGroup.sAMAccountName) = False)
> > Then
> > objGroupListComputer.Add objGroup.sAMAccountName, True
> > Call LoadGroupsComputer(objGroup)
> > End If
> >
> > Set objGroup = Nothing
> >
> > Exit Sub
> >
> > End If
> >
> > For j = 0 To UBound(colstrGroups)
> >
> > ' Escape any forward slash characters, "/", with the backslash
> > ' escape character. All other characters that should be escaped
> > are.
> >
> > colstrGroups(j) = Replace(colstrGroups(j), "/", "\/")
> >
> > Set objGroup = GetObject("LDAP://" & colstrGroups(j))
> >
> > If (objGroupListComputer.Exists(objGroup.sAMAccountName) = False)
> > Then
> > objGroupListComputer.Add objGroup.sAMAccountName, True
> > Call LoadGroupsComputer(objGroup)
> > End If
> >
> > Next
> >
> > Set objGroup = Nothing
> >
> > End Sub
>
>
>
My System SpecsSystem Spec
Old 09-17-2009   #4 (permalink)
Richard Mueller [MVP]


 
 

Re: WinNT error message

The following should fix most problems:

1. Replace all instances of vbCr with vbCrLf. With vbCr only the last line
shows up, as each line overwrites the previous.
2. Replace objUser.FullName with objUser.displayName. FullName is not
exposed by the LDAP provider.
3. Replace objUser.FirstName with objUser.givenName. FirstName is not
exposed by the LDAP provider.
4. As noted before, replace
Set ComputerObj = GetObject("WinNT://" & DomainString & "/" &
ComputerString)
with
Set ComputerObj = GetObject("WinNT://" & WshNetwork.UserDomain & "/" &
ComputerString)
5. IsMemberComptuer is mis-spelled in IsMemberComputer.

I added the following lines at the start when I tested the script:

Option Explicit
Dim strListUser, strFullName, strFirstName, strListComputer
Dim strGoupUser, strGroupComputer

This caught the mis-spelling. The program ran to completion for me.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--

"kane9522" <kane9522@newsgroup> wrote in message
news3FE443A-BFD9-4F81-A9E1-63121387FAD3@newsgroup
Quote:

> Hi Richard,
> using that WshNetwork.UserDomain has fixed the error
> message but is still not showing that the computer account is part of a
> particular group...I can check AD and see that the computer account
> definitely has the group I need to check it for, in this case
> 2003GG_NoPrintersConfig, the check works correctly for the user
> account...any
> ideas??
>
> "Richard Mueller [MVP]" wrote:
>
Quote:

>> First, there is probably no reason to use the WinNT provider. It is
>> slower
>> and reveals fewer attributes. If you do use it, use wshNetwork.UserDomain
>> to
>> retrieve the NetBIOS name of the domain. The value of RootDSE.dnsHostName
>> will be similar to:
>>
>> MyComputer.MyDomain.com
>>
>> where MyComputer is a Domain Controller.
>>
>> --
>> Richard Mueller
>> MVP Directory Services
>> Hilltop Lab - http://www.rlmueller.net
>> --
>>
>> "kane9522" <kane9522@newsgroup> wrote in message
>> news:45E24808-D861-44D9-964F-1F8EE0B59B6B@newsgroup
Quote:

>> > Hi All, I am having some trouble with a script I am trying to write, I
>> > am
>> > getting this error message:
>> >
>> > Error: The Group name could not be found
>> > Code: 800708AC
>> > Source: (null)
>> >
>> > what I am trying to do is determine whether a computer account in AD is
>> > part
>> > of global group, I have code to do the same thing with user accounts,
>> > and
>> > the
>> > user accounts code is working...the code for checking the computer is
>> > just
>> > a
>> > copy of the user checking code...I have tested the user code and know
>> > that
>> > it
>> > works, so one would assume that the computer checking code would also
>> > work...any help would be appreciated...
>> >
>> > Dim WshShell, WshEnv, objFSO, WshNetwork, objGroupListUser,
>> > objGroupListComputer, objUserMemberOf, objGroupUser,
>> > objComputerMemberOf,
>> > objGroupComputer
>> > Dim objSysInfoUser, objSysInfoComputer, objDomain, objCurrentUser,
>> > UserObj,
>> > objCurrentComputer, ComputerObj, objUser, objComputer
>> > Dim DomainString, UserString, ComputerString, strUser, strComputer
>> >
>> > Const OverwriteExisting = True
>> >
>> > 'On Error Resume Next
>> >
>> > 'Configures Variables
>> > Set objFSO = CreateObject("Scripting.FileSystemObject")
>> > Set WshShell = WScript.CreateObject("WScript.Shell")
>> > Set WshEnv = WshShell.Environment("Process")
>> > Set WshNetwork = CreateObject("WScript.Network")
>> >
>> > Set objSysInfoUser = CreateObject("ADSystemInfo")
>> > Set objSysInfoComputer = CreateObject("ADSystemInfo")
>> > Set objDomain = getObject("LDAP://rootDse")
>> > DomainString = objDomain.Get("dnsHostName")
>> >
>> > 'Get user name
>> > UserString = WshNetwork.UserName
>> > Set objCurrentUser = GetObject("LDAP://" & objSysInfoUser.UserName)
>> > Set UserObj = GetObject("WinNT://" & DomainString & "/" & UserString)
>> > strUser = objSysInfoUser.UserName
>> > Set objUser = GetObject("LDAP://" & strUser)
>> >
>> > 'Get Computer name
>> > ComputerString = WshNetwork.ComputerName
>> > Set objCurrentComputer = GetObject("LDAP://" &
>> > objSysInfoComputer.ComputerName)
>> >
>> > 'This is the line that causes the error
>> > Set ComputerObj = GetObject("WinNT://" & DomainString & "/" &
>> > ComputerString)
>> >
>> > 'Set ComputerObj = GetObject("WinNT://" & ComputerString)
>> > strComputer = objSysInfoComputer.ComputerName
>> > Set objComputer = GetObject("LDAP://" & strComputer)
>> >
>> >
>> >
>> > objUserMemberOf = objUser.GetEx("memberOf")
>> > For Each objGroupUser in objUserMemberOf
>> > strListUser = strListUser & objGroupUser & vbcr
>> > Next
>> >
>> > 'errors if computer has no groups...
>> > 'objComputerMemberOf = objComputer.GetEx("memberOf")
>> > 'For Each objGroupComputer in objComputerMemberOf
>> > ' strListComputer = strListComputer & objGroupComputer & vbcr
>> > 'Next
>> >
>> > strFullName = objUser.FullName
>> > strFirstName = objUser.FirstName
>> >
>> >
>> >
>> > wscript.echo "Domain: " & DomainString
>> > wscript.echo "Computer Network: " & ComputerString
>> > wscript.echo "Computer ADInfo: " & strComputer
>> > 'wscript.echo "Full Name " & strFullName
>> > 'wscript.echo "First Name " & strFirstName
>> > 'wscript.echo "strUser " & strUser
>> > 'wscript.echo "Username " & UserString
>> > WScript.Echo "Groups for " & strUser & vbCr & strListUser
>> > wscript.echo "Groups for " & strComputer & vbCr & strListComputer
>> >
>> >
>> > strGroupUser = "2003GG_NoPrintersConfig"
>> > If (IsMemberUser(strGroupUser) = True) Then
>> > Wscript.Echo "User " & objUser.name & " is a member of group " &
>> > strGroupUser
>> > ElseIf (IsMemberUser(strGroupUser) = False) Then
>> > Wscript.Echo "User " & objUser.name & " is NOT a member of group " &
>> > strGroupUser
>> > End If
>> >
>> > strGroupComputer = "2003GG_NoPrintersConfig"
>> > If (IsMemberComputer(strGroupComputer) = True) Then
>> > wscript.echo "Computer " & objComputer.name & " is a member of group "
>> > &
>> > strGroupComputer
>> > ElseIf (IsMemberComputer(strGroupComputer) = False) Then
>> > wscript.echo "Computer " & objComputer.name & " is not a member of
>> > group "
>> > & strGroupComputer
>> > End If
>> >
>> > Function IsMemberUser(ByVal strGroupUser)
>> >
>> > ' Function to test for group membership.
>> > ' strGroup is the NT name (sAMAccountName) of the group to test.
>> > ' objGroupList is a dictionary object, with global scope.
>> > ' Returns True if the user or computer is a member of the group.
>> >
>> > If (IsEmpty(objGroupListUser) = True) Then
>> > Set objGroupListUser = CreateObject("Scripting.Dictionary")
>> > Call LoadGroupsUser(objUser)
>> > End If
>> >
>> > IsMemberUser = objGroupListUser.Exists(strGroupUser)
>> >
>> > End Function
>> >
>> > Function IsMemberComputer(ByVal strGroupComputer)
>> >
>> > ' Function to test for group membership.
>> > ' strGroup is the NT name (sAMAccountName) of the group to test.
>> > ' objGroupList is a dictionary object, with global scope.
>> > ' Returns True if the user or computer is a member of the group.
>> >
>> > If (IsEmpty(objGroupListComputer) = True) Then
>> > Set objGroupListComputer = CreateObject("Scripting.Dictionary")
>> > Call LoadGroupsComputer(objComputer)
>> > End If
>> >
>> > IsMemberComptuer = objGroupListComputer.Exists(strGroupComputer)
>> >
>> > End Function
>> >
>> > Sub LoadGroupsUser(ByVal objUser)
>> >
>> > ' Recursive subroutine to populate dictionary object with group
>> > ' memberships. When this subroutine is first called by Function
>> > ' IsMember, objADObject is the user or computer object. On recursive
>> > calls
>> > ' objADObject will be a group object. For each group in the MemberOf
>> > ' collection, first check to see if the group is already in the
>> > ' dictionary object. If it is not, add the group to the dictionary
>> > ' object and recursively call this subroutine again to enumerate any
>> > ' groups the group might be a member of (nested groups). It is
>> > necessary
>> > ' to first check if the group is already in the dictionary object to
>> > ' prevent an infinite loop if the group nesting is "circular".
>> >
>> > Dim colstrGroups, objGroup, j
>> >
>> > objGroupListUser.CompareMode = vbTextCompare
>> >
>> > colstrGroups = objUser.memberOf
>> >
>> > If (IsEmpty(colstrGroups) = True) Then
>> > Exit Sub
>> > End If
>> >
>> > If (TypeName(colstrGroups) = "String") Then
>> >
>> > ' Escape any forward slash characters, "/", with the backslash
>> > ' escape character. All other characters that should be escaped
>> > are.
>> >
>> > colstrGroups = Replace(colstrGroups, "/", "\/")
>> >
>> > Set objGroup = GetObject("LDAP://" & colstrGroups)
>> >
>> > If (objGroupListUser.Exists(objGroup.sAMAccountName) = False)
>> > Then
>> > objGroupListUser.Add objGroup.sAMAccountName, True
>> > Call LoadGroupsUser(objGroup)
>> > End If
>> >
>> > Set objGroup = Nothing
>> >
>> > Exit Sub
>> >
>> > End If
>> >
>> > For j = 0 To UBound(colstrGroups)
>> >
>> > ' Escape any forward slash characters, "/", with the backslash
>> > ' escape character. All other characters that should be escaped
>> > are.
>> >
>> > colstrGroups(j) = Replace(colstrGroups(j), "/", "\/")
>> >
>> > Set objGroup = GetObject("LDAP://" & colstrGroups(j))
>> >
>> > If (objGroupListUser.Exists(objGroup.sAMAccountName) = False)
>> > Then
>> > objGroupListUser.Add objGroup.sAMAccountName, True
>> > Call LoadGroupsUser(objGroup)
>> > End If
>> >
>> > Next
>> >
>> > Set objGroup = Nothing
>> >
>> > End Sub
>> >
>> > Sub LoadGroupsComputer(ByVal objComputer)
>> >
>> > ' Recursive subroutine to populate dictionary object with group
>> > ' memberships. When this subroutine is first called by Function
>> > ' IsMember, objADObject is the user or computer object. On recursive
>> > calls
>> > ' objADObject will be a group object. For each group in the MemberOf
>> > ' collection, first check to see if the group is already in the
>> > ' dictionary object. If it is not, add the group to the dictionary
>> > ' object and recursively call this subroutine again to enumerate any
>> > ' groups the group might be a member of (nested groups). It is
>> > necessary
>> > ' to first check if the group is already in the dictionary object to
>> > ' prevent an infinite loop if the group nesting is "circular".
>> >
>> > Dim colstrGroups, objGroup, j
>> >
>> > objGroupListComputer.CompareMode = vbTextCompare
>> >
>> > colstrGroups = objComputer.memberOf
>> >
>> > If (IsEmpty(colstrGroups) = True) Then
>> > Exit Sub
>> > End If
>> >
>> > If (TypeName(colstrGroups) = "String") Then
>> >
>> > ' Escape any forward slash characters, "/", with the backslash
>> > ' escape character. All other characters that should be escaped
>> > are.
>> >
>> > colstrGroups = Replace(colstrGroups, "/", "\/")
>> >
>> > Set objGroup = GetObject("LDAP://" & colstrGroups)
>> >
>> > If (objGroupListComputer.Exists(objGroup.sAMAccountName) =
>> > False)
>> > Then
>> > objGroupListComputer.Add objGroup.sAMAccountName, True
>> > Call LoadGroupsComputer(objGroup)
>> > End If
>> >
>> > Set objGroup = Nothing
>> >
>> > Exit Sub
>> >
>> > End If
>> >
>> > For j = 0 To UBound(colstrGroups)
>> >
>> > ' Escape any forward slash characters, "/", with the backslash
>> > ' escape character. All other characters that should be escaped
>> > are.
>> >
>> > colstrGroups(j) = Replace(colstrGroups(j), "/", "\/")
>> >
>> > Set objGroup = GetObject("LDAP://" & colstrGroups(j))
>> >
>> > If (objGroupListComputer.Exists(objGroup.sAMAccountName) =
>> > False)
>> > Then
>> > objGroupListComputer.Add objGroup.sAMAccountName, True
>> > Call LoadGroupsComputer(objGroup)
>> > End If
>> >
>> > Next
>> >
>> > Set objGroup = Nothing
>> >
>> > End Sub
>>
>>
>>

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Windows Mail Error Sending a Message - Non-specific Error Message Vista mail
WINNT.SIF Vista installation & setup
WINNT.SIF support? Vista installation & setup
Vista and WinNT domain Vista General
setup from DOS and winnt.exe Vista installation & setup


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46