Hi!, i want to connect network drives by querying the username and
who's he member of. This is because, depending on which group he
belongs to I'll connect one folder or another.
i use the On Error resume next, so if there's problem querying the
information or connecting i dont know about it.
I found two problems:
1 - rarely, when I log in, the network drive doesnt get connected, but
if i logoff and logon back again everything's ok.-
2 - a little bit more often when i put my username and password,
windows validates it, i hear the "ding ding ding ding" but Explorer
simply doesnt load, so no systray, no desktop; if i press ctrl alt
del, and then run explorer manually, everything seems ok.
This last problem is quite annoying and i dont know what's wrong, I
know its the script though.-
HERE'S THE SCRIPT:
////////////////////////////////////////////////////////////////////////////=
///////////////////////////////////////////////////////////////////////
Option Explicit
dim FServer
Dim wshNetwork
Dim sys
Dim carpeta
Dim objUser
Dim colGroups
Dim objGroup
'on error goto Errores
If WScript.Arguments.Count <> 1 Then
Wscript.Echo "Se pasaron " & WScript.Arguments.Count & " argumento(s)"
Wscript.Echo "Usage: CScript.exe script.vbs \\servidor\ =A1Con la doble
barra y la del final!"
WScript.Quit
End If
Fserver =3D WScript.Arguments(0)
'Lo que obtengo via LDAP lo repito 5 veces, **** cuestiones de
latencia.
'Obtengo el nombre de usuario, OU y otras cosas.
Set sys =3D CreateObject("ADSystemInfo")
'Obtengo los grupos de seguridad y extraigo el SEC
Set objUser =3D GetObject _
("LDAP://" & sys.UserName)
Set colGroups =3D objUser.Groups
For Each objGroup in colGroups
if UCASE(mid(objGroup.CN,1,3)) =3D "SEC" then 'Separa las 3 primeras
letras, busco el SEC*
carpeta=3D mid(objGroup.CN,4,len(objGroup.CN))
END if
next
'Ya tengo el nombre de la fiscalia.
Set wshNetwork =3D CreateObject("Wscript.Network")
on error resume next
wshNetwork.MapNetworkDrive "u:", Fserver & carpeta
Wscript.Echo "Bienvenido al Dominio MPF, tiene su espacio compartido
en la unidad U:\, en MiPC"
WSCript.Quit
////////////////////////////////////////////////////////////////////////////=
////////////////////////////////////////////////////////////////


|