Re: List and remap shares



Daniel wrote:
Check this article, I think it addresses your issue

http://www.microsoft.com/technet/scriptcenter/resources/qanda/sept05/hey0928.mspx

Hope this help,

Daniel


Thanks, that did it. I was able to hack this little guy together. I don't quite have the hang of VBS, so if the user doesn't enter a userid or password, while the program complains it doesn't abort.


For anyone curious, I've discovered that while windowes will prevent you from connecting to file shares on a server with different userids, it only cares about what you call the server not the actual address. So you can end up with one userid for \\servername\shareone and a different userid for \\servername.my.domain\sharetwo

What is really fun is when you have a clueless user who has been setup by fellow helpful users with different philosophies. So one person maps him to a drive with \\server.my.domain\share and his ID and another maps him to \\127.0.0.1\sharetwo (the IP address of the server) because he doesn't trust the DNS servers.

The user is using the same userid for both shares, and then changes his password some months later(non-integrated network) and corrects it on one shaename. Meanwhile the computer will happily keep trying to reconnect him on bootup to the other share and failing. If he has enough of these shares, he can get himself locked out after too many failures.

Thus I needed a utility to get all the different sharenames and map them all to one std.


---remap.vbs---- Const ServerNAME = "\\servername\" Const ServerFQDN = "\\servername.my.domain\" Const ServerIP = "\\127.0.0.1\"

Dim mapnewDrives()

numDrives = 0

newuserid = InputBox("Please enter your userid for " & ServerFQDN & ":")
If newuserid = "" Then
Wscript.Echo "No userid entered"
End If
newpassword = InputBox("Please enter your password for " & ServerFQDN & ":")
If newpassword = "" Then
Wscript.Echo "No userid entered"
End If


Set objNetwork = CreateObject("Wscript.Network")

Set colDrives = objNetwork.EnumNetworkDrives

For i = 0 to colDrives.Count-1 Step 2
shareData = colDrives.item(i+1)
pos = InStrRev(shareData, "\")
shareName = Mid(shareData,pos+1)
InAny = 0
InAny = InStr(1, shareData, ServerNAME, vbTextCompare) + InStr(1, shareData, ServerFQDN, vbTextCompare) + InStr(1, shareData, ServerIP, vbTextCompare)
wscript.echo shareData
wscript.echo InAny
If InAny > 0 Then
strDriveLetter = colDrives.Item(i)
numDrives = numDrives + 2
Redim Preserve mapnewDrives(numDrives)
mapnewDrives(numDrives - 2) = StrDriveLetter
mapnewDrives(numDrives - 1) = ServerFQDN & shareName
objNetwork.RemoveNetworkDrive strDriveLetter, True, True
End If
Next


For i = 0 to (numDrives -1) Step 2
objNetwork.MapNetworkDrive mapnewDrives(i), mapnewDrives(i+1), true, newuserid, newpassword
Next
---remap.vbs----
.




Relevant Pages

  • Re: schedule job - login in dynamic sql
    ... If the user created the stored proc without ... You have a userid as the login on the server. ... usually the Agent userid is a member of the sysadmin, or at least of dbo), ...
    (microsoft.public.sqlserver.programming)
  • Re: WSS: Finding My Sites through SQL
    ... sites on a diferent server than the WSS server. ... foreach (XmlNode node in AllSites) ... and I came up with this SQL: ... Select @userId = tp_ID from UserInfo where tp_login like 'DOMAIN ...
    (microsoft.public.sharepoint.windowsservices)
  • WSS: Finding My Sites through SQL
    ... sites on a diferent server than the WSS server. ... foreach (XmlNode node in AllSites) ... and I came up with this SQL: ... Select @userId = tp_ID from UserInfo where tp_login like 'DOMAIN ...
    (microsoft.public.sharepoint.windowsservices)
  • Re: login info from ie screen
    ... windows userid from the client machine, but it displays another userid that ... As if there is miscommunication between client and windows 2003 server. ... >> intranet userid that is different than her actual windows userid. ...
    (microsoft.public.frontpage.client)
  • Re: Appending a unique line to a file
    ... On OS/2 (our previous server) this was simple, as you couldn't open a file for output on more than one thread; OS/2 caused the second to fail. ... call rxqueue 'create', 'myQ' ... say 'Received:' userid ...
    (comp.lang.rexx)