Can anyone help me please.
I am trying to split a users homedrive which I input using the
following code, the problem is I get an error when trying to split the
name. I basically want to get the servername and the home drive share
name as two seperate values so I can then use them seperatly.
The Home drive is displayed as "\\Servername\Sharename$"
username = "HJSimpson"
Const ADS_PROPERTY_DELETE = 4
Const ADS_PROPERTY_APPEND = 3
'Open connection to AD using LDAP
Set objCommand = CreateObject("ADODB.Command")
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
objCommand.ActiveConnection = objConnection
strBase = "<LDAP://dc=name,dc=name>"
strFilter = "(&(objectCategory=person)(sAMAccountName=" & username &
"))"
strAttributes = "sAMAccountName,AdsPath,distinguishedName"
strQuery = strBase & ";" & strFilter & ";" & strAttributes
objCommand.CommandText = strQuery
Set ADSIRecordSet = objCommand.Execute
strName = ADSIRecordSet.Fields("sAMAccountName").Value
errorNum = err.number
errorDesc = err.description
strAdsPath = ADSIRecordSet.Fields("AdsPath").Value
strDN = ADSIRecordSet.Fields("distinguishedName").Value
Set objUser = GetObject("LDAP://" & strDN)
strDisplayName = objUser.displayname
strDescription = objUser.description
err.number = "0"
Set usr = GetObject(strAdsPath)
homedir = usr.homedirectory
MsgBox homedir - This bit is OK
a=Split(homedir,"\",-1,1) - This bit is not OK.
If InStr(a, "\\") Then
newservername = len(a,3)
Else
'Do Nothing
End If
MsgBox newservername
WScript.Quit:
Please help. Thanks