' VB Logon Script to Map Drives to AFS via the Open AFS Client ' Written by Ian Byrne, OIT, 631-5742 ' Jan 15 2002 ' Modified 8/12 to Run AFS_Recover to ensure service is started and user has tokens 'On Error Resume Next ' Make sure the Workstation service is started Set WShell = CreateObject("WScript.Shell") WShell.Run """" & "net" & """" & "start workstation", 0, True ' Create ADO Object to Query Directory.nd.edu LDAP Server for ' Users Home Path in AFS Set Conn = CreateObject("ADODB.Connection") Set RS = CreateObject("ADODB.Recordset") ' Create Windows Script Network Object to Map Network Drives Set NW = createObject("WScript.Network") ' Get the username of the currently logged on user strUserName = NW.Username ' Get the computer Name strComputerName = NW.ComputerName ' Connect to ND Campus LDAP Directory and Search for Username ' Once found lookup AFS Home Path for the currently logged on User Conn.Provider = "ADsDSOObject" Conn.Open "ADSI" strSearchOptions = "uid='" & strUserName & "'" Set RS = Conn.Execute("SELECT ndPvid, ndUnixHomeDir FROM 'LDAP://Directory.nd.edu/o=university of notre dame,st=Indiana,c=us' WHERE " & strSearchOptions) While Not RS.EOF strAFSID = RS.Fields("ndPvid") strndUnixHome = RS.Fields("ndUnixHomeDir") RS.MoveNext Wend RS.Close Conn.Close If strAFSID <> "" Then Set FSO = CreateObject("Scripting.FileSystemObject") If FSO.FolderExists("C:\AFS_RECOVER") = True Then WShell.Run "C:\AFS_RECOVER\AFS_RECOVER.EXE", 0, True Else ' I have to copy klog.exe from C:\Program Files\IBM\AFS\Client\Program\ ' WShell.Run "%windir%\System32\klog.exe", 1, true ' Parse Home Path for User Number - Users Directory in AFS is in the ' Format: /nd.edu/user#/AFS ID intStartPos = instr(strndUnixHome, "/nd.edu/") + 1 intEndPos = Len(strndUnixHome) + 1 intLength = intEndPos - intStartPos AFS_Home_Drive = Mid(strndUnixHome, intStartPos, intLength) AFS_Home_Drive = Replace(AFS_Home_Drive, "/", "\") ' Map Drives To AFS AFS_Home_Drive = "\\afs\all\" & AFS_Home_Drive AFS_CourseWare = "\\afs\all\" & "nd.edu\access" AFS_ND_EDU = "\\afs\all\" & "nd.edu" NW.MapNetworkDrive "H:", AFS_Home_Drive, False NW.MapNetworkDrive "I:", AFS_CourseWare, False NW.MapNetworkDrive "J:", AFS_ND_EDU, False WScript.echo "Hello " & strUserName & ", you can use your H:\ drive now." End If End If