[gptalk] Re: New Twist on old problem - Script set to wait on network - but inside script network names not resolved
- From: "Darren Mar-Elia" <darren@xxxxxxxxxx>
- To: <gptalk@xxxxxxxxxxxxx>
- Date: Thu, 20 Nov 2008 07:17:48 -0800
In addition, I have seen this happen even when everything is fine. I think
it ends up being a timing issue. What I always recommend to folks is that if
you're going to use logon scripts, (or startup scripts) put some logging
into them so that you can catch errors. That's the only way you can really
tell when something is happening.
Darren
From: gptalk-bounce@xxxxxxxxxxxxx [mailto:gptalk-bounce@xxxxxxxxxxxxx] On
Behalf Of Omar Droubi
Sent: Wednesday, November 19, 2008 4:00 PM
To: gptalk@xxxxxxxxxxxxx
Subject: [gptalk] Re: New Twist on old problem - Script set to wait on
network - but inside script network names not resolved
No- not if one DNS server is ok and the other is not-that is why you would
check both of them. But if there is only 1 DNS server then-I would check to
see if the file server has more than A (host) record as when a DNS record is
queried- all matching records are returned
For example: on a server named server1.domain.com you can get 192.168.5.1,
192.168.0.1 and 192.168.5.3- Say for example 192.168.0.1 was the old IP
address- when a client queries this record all three will be returned- but
when connecting to the server the Windows client will 1st try 192.168.5.1
and the next connection attempt will try 192.168.0.1 and so on.
Now in any of these situations- you would get more frequent failures-so I
just recommend that you verify all FWD and reverse DNS records- and then
take the DNS out of the picture as OK.
From: gptalk-bounce@xxxxxxxxxxxxx [mailto:gptalk-bounce@xxxxxxxxxxxxx] On
Behalf Of Booker.Washington@xxxxxxxxxxxxxx
Sent: Wednesday, November 19, 2008 3:19 PM
To: gptalk@xxxxxxxxxxxxx
Subject: [gptalk] Re: New Twist on old problem - Script set to wait on
network - but inside script network names not resolved
IF the DNS were screwed up, wouldn't it happen everytime?
Booker T. Washington III
Systems Support Specialist
404-894-8716 direct
404-385-5188 alt
From: gptalk-bounce@xxxxxxxxxxxxx [mailto:gptalk-bounce@xxxxxxxxxxxxx] On
Behalf Of Omar Droubi
Sent: Wednesday, November 19, 2008 5:15 PM
To: gptalk@xxxxxxxxxxxxx
Subject: [gptalk] Re: New Twist on old problem - Script set to wait on
network - but inside script network names not resolved
One of things I usually do is separate the wait for network startup and run
logon script synchronously on a separate GPO that only applies these
settings to computer objects (of course I only define these settings in the
computer configuration section)
Then I just run the user GPO separately- applied to user accounts of course.
Regarding your particular issue- I would verify that the DNS server IP
addresses that are assigned to the workstations have properly configured
forward and reverse DNS entries in their DNS table- and that both the DNS
servers have the correct DNS entries for the file server. I think the
problem is in here -IMHO
Omar
From: gptalk-bounce@xxxxxxxxxxxxx [mailto:gptalk-bounce@xxxxxxxxxxxxx] On
Behalf Of Booker.Washington@xxxxxxxxxxxxxx
Sent: Wednesday, November 19, 2008 12:56 PM
To: gptalk@xxxxxxxxxxxxx
Subject: [gptalk] New Twist on old problem - Script set to wait on network -
but inside script network names not resolved
OK, I have the script below, and inside of the GPO, the settings are set for
Always wait for the network at computer startup and logon
And
Run logon scripts synchronously
But intermittently (And only once thus far), when it tries to map a drive, I
will get an error that the network name could not be found.
If I log off and log back on, then no problem.
Could I be missing a setting to make sure everything involved with name
recognition is initialized and ready to resolve names
Script contents below
Option Explicit
Dim objSysInfo, objNetwork, strUserPath, objUser
Dim adoCommand, adoConnection, strBase, strAttributes
Dim objGroupList
Set objSysInfo = CreateObject("ADSystemInfo")
Set objNetwork = CreateObject("Wscript.Network")
strUserPath = "LDAP://" & objSysInfo.UserName
Set objUser = GetObject(strUserPath)
'Removes curent mappings
On Error Resume Next
objNetwork.RemoveNetworkDrive "L:", True, True
objNetwork.RemoveNetworkDrive "J:", True, True
objNetwork.RemoveNetworkDrive "Z:", True, True
objNetwork.RemoveNetworkDrive "R:", True, True
objNetwork.RemoveNetworkDrive "N:", True, True
objNetwork.RemoveNetworkDrive "O:", True, True
objNetwork.RemoveNetworkDrive "U:", True, True
objNetwork.RemoveNetworkDrive "S:", True, True
objNetwork.RemoveNetworkDrive "M:", True, True
objNetwork.RemoveNetworkDrive "I:", True, True
objNetwork.RemoveNetworkDrive "K:", True, True
objNetwork.RemoveNetworkDrive "Z:", True, True
objNetwork.RemoveNetworkDrive "X:", True, True
objNetwork.RemoveNetworkDrive "Y:", True, True
objNetwork.RemoveNetworkDrive "Q:", True, True
On Error GoTo 0
If (IsMember(objUser, "GTS IT Services Group") = True) Then
objNetwork.MapNetworkDrive "Y:", _
"\\filesrvr-01.domain.com\com\shares\groups\IT services", False
End If
If (IsMember(objUser, "GTS Career Services") = True) Then
objNetwork.MapNetworkDrive "L:", _
"\\filesrvr-01.domain.com\com\shares\groups\Career Services", False
objNetwork.MapNetworkDrive "J:", _
"\\filesrvr-01.domain.com\com\shares\groups\Career Svcs_Act", False
objNetwork.MapNetworkDrive "Z:", _
"\\filesrvr-01.domain.com\com\shares\groups\Undergraduate Office", False
End If
If (IsMember(objUser, "GTS Career Services SAs") = True) Then
objNetwork.MapNetworkDrive "L:", _
"\\filesrvr-01.domain.com\com\shares\groups\Career Services", False
objNetwork.MapNetworkDrive "J:", _
"\\filesrvr-01.domain.com\com\shares\groups\Career Svcs_Act", False
objNetwork.MapNetworkDrive "Z:", _
"\\filesrvr-01.domain.com\com\shares\groups\Undergraduate Office", False
End If
If (IsMember(objUser, "GTS CIBER") = True) Then
objNetwork.MapNetworkDrive "R:", _
"\\filesrvr-01.domain.com\com\shares\groups\CIBER", False
End If
If (IsMember(objUser, "GTS Communications") = True) Then
objNetwork.MapNetworkDrive "R:", _
"\\filesrvr-01.domain.com\com\shares\groups\Communications", False
objNetwork.MapNetworkDrive "N:", _
"\\filesrvr-01.domain.com\com\shares\groups\DeanSuite", False
End If
If (IsMember(objUser, "GTS Communications Share Guest access") = True) Then
objNetwork.MapNetworkDrive "R:", _
"\\filesrvr-01.domain.com\com\shares\groups\Communications", False
objNetwork.MapNetworkDrive "N:", _
"\\filesrvr-01.domain.com\com\shares\groups\DeanSuite", False
End If
If (IsMember(objUser, "GTS Dean Suite non HR") = True) Then
objNetwork.MapNetworkDrive "L:", _
"\\filesrvr-01.domain.com\com\shares\groups\Building Operations", False
objNetwork.MapNetworkDrive "N:", _
"\\filesrvr-01.domain.com\com\shares\groups\DeanSuite", False
objNetwork.MapNetworkDrive "O:", _
"\\filesrvr-01.domain.com\com\shares\groups\Accounting", False
objNetwork.MapNetworkDrive "U:", _
"\\filesrvr-01.domain.com\com\shares\groups\Graduate Assistantship", False
objNetwork.MapNetworkDrive "S:", _
"\\filesrvr-01.domain.com\com\shares\groups\Accounting\FAcS", False
End If
If (IsMember(objUser, "GTS Development") = True) Then
objNetwork.MapNetworkDrive "L:", _
"\\filesrvr-01.domain.com\com\shares\groups\Development", False
objNetwork.MapNetworkDrive "R:", _
"\\filesrvr-01.domain.com\com\shares\groups\Communications", False
objNetwork.MapNetworkDrive "M:", _
"\\filesrvr-01.domain.com\com\shares\groups\Development\Student Share",
False
objNetwork.MapNetworkDrive "N:", _
"\\filesrvr-01.domain.com\com\shares\groups\DeanSuite", False
End If
If (IsMember(objUser, "GTS Development SAs") = True) Then
objNetwork.MapNetworkDrive "M:", _
"\\filesrvr-01.domain.com\com\shares\groups\Development\Student Share",
False
End If
If (IsMember(objUser, "GTS Eview Users") = True) Then
objNetwork.MapNetworkDrive "Y:", _
"\\filesrvr-01.domain.com\com\shares\groups\eview", False
End If
If (IsMember(objUser, "GTS Executive Masters") = True) Then
objNetwork.MapNetworkDrive "I:", _
"\\filesrvr-01.domain.com\com\shares\groups\Executive Education", False
objNetwork.MapNetworkDrive "J:", _
"\\filesrvr-01.domain.com\com\shares\groups\EMSMOT_Act", False
objNetwork.MapNetworkDrive "K:", _
"\\filesrvr-01.domain.com\com\shares\groups\EMSMOT", False
objNetwork.MapNetworkDrive "O:", _
"\\filesrvr-01.domain.com\com\shares\groups\Accounting", False
objNetwork.MapNetworkDrive "L:", _
"\\filesrvr-01.domain.com\com\shares\groups\Executive Programs", False
End If
If (IsMember(objUser, "GTS Executive Programs") = True) Then
objNetwork.MapNetworkDrive "I:", _
"\\filesrvr-01.domain.com\com\shares\groups\Executive Education", False
objNetwork.MapNetworkDrive "J:", _
"\\filesrvr-01.domain.com\com\shares\groups\EMSMOT_Act", False
objNetwork.MapNetworkDrive "K:", _
"\\filesrvr-01.domain.com\com\shares\groups\EMSMOT", False
objNetwork.MapNetworkDrive "O:", _
"\\filesrvr-01.domain.com\com\shares\groups\Accounting", False
objNetwork.MapNetworkDrive "L:", _
"\\filesrvr-01.domain.com\com\shares\groups\Executive Programs", False
End If
If (IsMember(objUser, "GTS Explab Share participants") = True) Then
objNetwork.MapNetworkDrive "Z:", _
"\\filesrvr-01.domain.com\com\shares\groups\Explab", False
End If
If (IsMember(objUser, "GTS Graduate Office") = True) Then
objNetwork.MapNetworkDrive "M:", _
"\\filesrvr-01.domain.com\com\shares\groups\Graduate Office", False
End If
If (IsMember(objUser, "GTS Grad Assistant Share") = True) Then
objNetwork.MapNetworkDrive "U:", _
"\\filesrvr-01.domain.com\com\shares\groups\Graduate Assistantship", False
End If
If (IsMember(objUser, "GTS HR staff") = True) Then
objNetwork.MapNetworkDrive "X:", _
"\\filesrvr-01.domain.com\com\shares\groups\Building Operations", False
objNetwork.MapNetworkDrive "N:", _
"\\filesrvr-01.domain.com\com\shares\groups\DeanSuite", False
objNetwork.MapNetworkDrive "O:", _
"\\filesrvr-01.domain.com\com\shares\groups\Accounting", False
objNetwork.MapNetworkDrive "Y:", _
"\\filesrvr-01.domain.com\com\shares\groups\Communications", False
objNetwork.MapNetworkDrive "R:", _
"\\filesrvr-01.domain.com\com\shares\groups\Human Resources", False
objNetwork.MapNetworkDrive "Q:", _
"\\filesrvr-01.domain.com\com\shares\groups\Accounting\Pcard", False
End If
If (IsMember(objUser, "ILE Office") = True) Then
objNetwork.MapNetworkDrive "J:", _
"\\filesrvr-01.domain.com\com\shares\groups\Institute for LE", False
End If
If (IsMember(objUser, "ILE GRAs") = True) Then
objNetwork.MapNetworkDrive "J:", _
"\\filesrvr-01.domain.com\com\shares\groups\Institute for LE", False
End If
If (IsMember(objUser, "GTS Tiger Share participants") = True) Then
objNetwork.MapNetworkDrive "R:", _
"\\filesrvr-01.domain.com\com\shares\groups\Tiger", False
End If
If (IsMember(objUser, "GTS Undergraduate Office") = True) Then
objNetwork.MapNetworkDrive "M:", _
"\\filesrvr-01.domain.com\com\shares\groups\Undergraduate Office", False
End If
If (IsMember(objUser, "GTS Recruiting Share Access") = True) Then
objNetwork.MapNetworkDrive "Q:", _
"\\filesrvr-01.domain.com\com\shares\groups\Recruiting", False
End If
If (IsMember(objUser, "GTS Faculty") = True) Then
objNetwork.MapNetworkDrive "S:", _
"\\filesrvr-01.domain.com\com\shares\groups\Accounting\FAcS", False
End If
Function IsMember(ByVal objADObject, ByVal strGroupNTName)
' Function to test for group membership.
' objADObject is a user or computer object.
' strGroupNTName 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.
' Subroutine LoadGroups is called once for each different objADObject.
Dim objRootDSE, strDNSDomain
' The first time IsMember is called, setup the dictionary object
' and objects required for ADO.
If (IsEmpty(objGroupList) = True) Then
Set objGroupList = CreateObject("Scripting.Dictionary")
objGroupList.CompareMode = vbTextCompare
Set adoCommand = CreateObject("ADODB.Command")
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADsDSOObject"
adoConnection.Open "Active Directory Provider"
adoCommand.ActiveConnection = adoConnection
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("defaultNamingContext")
adoCommand.Properties("Page Size") = 100
adoCommand.Properties("Timeout") = 30
adoCommand.Properties("Cache Results") = False
' Search entire domain.
strBase = "<LDAP://" & strDNSDomain & ">"
' Retrieve NT name of each group.
strAttributes = "sAMAccountName"
' Load group memberships for this user or computer into dictionary
' object.
Call LoadGroups(objADObject)
Set objRootDSE = Nothing
End If
If (objGroupList.Exists(objADObject.sAMAccountName & "\") = False) Then
' Dictionary object established, but group memberships for this
' user or computer must be added.
Call LoadGroups(objADObject)
End If
' Return True if this user or computer is a member of the group.
IsMember = objGroupList.Exists(objADObject.sAMAccountName & "\" _
& strGroupNTName)
End Function
Sub LoadGroups(ByVal objADObject)
' Subroutine to populate dictionary object with group memberships.
' objGroupList is a dictionary object, with global scope. It keeps track
' of group memberships for each user or computer separately. ADO is used
' to retrieve the name of the group corresponding to each objectSid in
' the tokenGroup array. Based on an idea by Joe Kaplan.
Dim arrbytGroups, k, strFilter, adoRecordset, strGroupName, strQuery
' Add user name to dictionary object, so LoadGroups need only be
' called once for each user or computer.
objGroupList.Add objADObject.sAMAccountName & "\", True
' Retrieve tokenGroups array, a calculated attribute.
objADObject.GetInfoEx Array("tokenGroups"), 0
arrbytGroups = objADObject.Get("tokenGroups")
' Create a filter to search for groups with objectSid equal to each
' value in tokenGroups array.
strFilter = "(|"
If (TypeName(arrbytGroups) = "Byte()") Then
' tokenGroups has one entry.
strFilter = strFilter & "(objectSid=" _
& OctetToHexStr(arrbytGroups) & ")"
ElseIf (UBound(arrbytGroups) > -1) Then
' TokenGroups is an array of two or more objectSid's.
For k = 0 To UBound(arrbytGroups)
strFilter = strFilter & "(objectSid=" _
& OctetToHexStr(arrbytGroups(k)) & ")"
Next
Else
' tokenGroups has no objectSid's.
Exit Sub
End If
strFilter = strFilter & ")"
' Use ADO to search for groups whose objectSid matches any of the
' tokenGroups values for this user or computer.
strQuery = strBase & ";" & strFilter & ";" _
& strAttributes & ";subtree"
adoCommand.CommandText = strQuery
Set adoRecordset = adoCommand.Execute
' Enumerate groups and add NT name to dictionary object.
Do Until adoRecordset.EOF
strGroupName = adoRecordset.Fields("sAMAccountName").Value
objGroupList.Add objADObject.sAMAccountName & "\" _
& strGroupName, True
adoRecordset.MoveNext
Loop
adoRecordset.Close
Set adoRecordset = Nothing
End Sub
Function OctetToHexStr(ByVal arrbytOctet)
' Function to convert OctetString (byte array) to Hex string,
' with bytes delimited by \ for an ADO filter.
Dim k
OctetToHexStr = ""
For k = 1 To Lenb(arrbytOctet)
OctetToHexStr = OctetToHexStr & "\" _
& Right("0" & Hex(Ascb(Midb(arrbytOctet, k, 1))), 2)
Next
End Function
Booker T. Washington III
Systems Support Specialist
Other related posts: