Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
[green]
'==========================================================================
'
' NAME: GetLogonServer.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: http://www.thespidersparlor.com
' DATE : 6/3/2005
'
' COMMENT: <comment>
'
'==========================================================================[/green]
[blue]Set WSHShell = CreateObject("Wscript.Shell")[/blue]
Set WSHProcess = WSHShell.Environment("Process")
[green]'Determine logon server[/green]
DomainLogonServer = WSHProcess("LogonServer")
[green]'Note: Results below will be \\Server[/green]
WScript.Echo "Login server is:"& DomainLogonServer
[green]
'==========================================================================
'
' NAME: GetLogonServer.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: http://www.thespidersparlor.com
' DATE : 6/3/2005
'
' COMMENT: <comment>
'
'==========================================================================[/green]
[blue]Set WSHShell = CreateObject("Wscript.Shell")[/blue]
Set WSHProcess = WSHShell.Environment("Process")
[green]'Determine logon server[/green]
DomainLogonServer = WSHProcess("LogonServer")
[green]'Note: Results will be in format \\Server[/green]
[green]'Now check for the value and map a drive[/green]
Select Case DomainLogonServer
Case "\\LASVR"
WSHNetwork.MapNetworkDrive "X:", "\\LASVR\executables",True
Case "\\PHXSVR"
WSHNetwork.MapNetworkDrive "X:", "\\PHXSVR\executables",True
Case "\\DALSVR"
WSHNetwork.MapNetworkDrive "X:", "\\DALSVR\executables",True
End Select
[green]
'==========================================================================
'
' NAME: GetDHCPIPaddress.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: http://www.thespidersparlor.com
' DATE : 5/4/2005
'
' COMMENT: Determines current DHCP IP Address of computer
' Assumes that there is only ONE active NIC.
'==========================================================================[/green]
On Error Resume Next
Const HKEY_LOCAL_MACHINE = &H80000002
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
".\root\default:StdRegProv")
[blue]Set WSHShell = CreateObject("Wscript.Shell")[/blue]
strKeyPath = "SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\"
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
For Each subkey In arrSubKeys
DHCPAddress = WSHShell.RegRead("HKLM\" & strKeyPath & subkey & "\DhcpIPAddress")
If DHCPAddress <> "0.0.0.0" And Left(DHCPAddress,3) <> "169" Then
ActiveDHCPIPAddress = DHCPAddress
End If
Next
[green]'Now that we have the DHCP Address let's do something with it
[green]'Grab the left 10 digits to determine subnet (example 192.168.1. or 192.168.2.)[/green]
[green]'Modify the length as needed for your available subnets.[/green]
Select Case Left(ActiveDHCPIPAddress,10)
Case "192.168.1."
WSHNetwork.MapNetworkDrive "X:", "\\LASVR\executables",True
Case "192.168.2."
WSHNetwork.MapNetworkDrive "X:", "\\PHXSVR\executables",True
Case "192.168.3."
WSHNetwork.MapNetworkDrive "X:", "\\DALSVR\executables",True
End Select
[blue]
Set WSHNetwork = CreateObject("WScript.Network")
strComputer = WSHNetwork.ComputerName[/blue]
Select Case Left(strComputer,3)
Case "Los"
WSHNetwork.MapNetworkDrive "X:", "\\LASVR\executables",True
Case "Phx"
WSHNetwork.MapNetworkDrive "X:", "\\PHXSVR\executables",True
Case "Dal"
WSHNetwork.MapNetworkDrive "X:", "\\DALSVR\executables",True
End Select
[green]
'==========================================================================
'
' NAME: <FindUserOU.vbs>
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: http://www.thespidersparlor.com
' DATE : 6/25/2005
'
' COMMENT: Thanks go out to Tek-Tips user K0b3 for the
' SearchDistinguishedName function.
'
'==========================================================================
' Code assumes you have already grabbed the user login name as UserString
'First grab the DistinguishedName[/green]
UserDN = SearchDistinguishedName(UserString)
[green]'Now bind to the user object[/green]
Set UserObj = GetObject("LDAP://" & UserDN)
[green]'Find the Relative Distinguished Name (RDN)[/green]
UserRDN = UserObj.Name
[green]'Subtract the length of the RDN plus one more for the comma
'You now have the full path to the users OU[/green]
UserOU = Right(UserDN,Len(UserDN)-Len(UserRDN)-1)
WScript.Echo UserOU
Public Function SearchDistinguishedName(ByVal vSAN)
[green] ' Function: SearchDistinguishedName
' Description: Searches the DistinguishedName for a given SamAccountName
' Parameters: ByVal vSAN - The SamAccountName to search
' Returns: The DistinguishedName Name[/green]
Dim oRootDSE, oConnection, oCommand, oRecordSet
Set oRootDSE = GetObject("LDAP://rootDSE")
Set oConnection = CreateObject("ADODB.Connection")
oConnection.Open "Provider=ADsDSOObject;"
Set oCommand = CreateObject("ADODB.Command")
oCommand.ActiveConnection = oConnection
oCommand.CommandText = "<LDAP://" & oRootDSE.get("defaultNamingContext") & _
">;(&(objectCategory=User)(samAccountName=" & vSAN & "));distinguishedName;subtree"
Set oRecordSet = oCommand.Execute
On Error Resume Next
SearchDistinguishedName = oRecordSet.Fields("DistinguishedName")
On Error GoTo 0
oConnection.Close
Set oRecordSet = Nothing
Set oCommand = Nothing
Set oConnection = Nothing
Set oRootDSE = Nothing
End Function