Solved

The specified network password is not correct error during script execution

Posted on 2007-11-16
5
2,477 Views
Last Modified: 2012-05-05
I am running the script attached and getting the error below
---------------------------
Windows Script Host
---------------------------
Script:      C:\Documents and Settings\user\Desktop\mappingdrives.vbs
Line:      32
Char:      13
Error:      The specified network password is not correct.

Code:      80070056
Source:       WSHNetwork.MapNetworkDrive

---------------------------
OK  
---------------------------

Line 32 in my script is objNetwork.MapNetworkDrive strDrive, strShare, True, True
'==============
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
 
Dim objNetwork
Set objNetwork = CreateObject("WScript.Network")
 
Dim objWinntUser
Set objWinntUser = GetObject("WinNT://" & objNetwork.UserDomain & "/" & objNetwork.UserName & ",user")
 
Dim strGroupToCheck, strGroupShare, strDrive, strShare
 
' Specity the group name, a semi-colon symbol, the drive letter, a semi-colon symbol, and the network share
arrGroupShares = Array( _
      "group1;Z;\\server\network\share1", _
      "group2;I;\\server\network\share2" _
      )
 
For Each strGroupShare In arrGroupShares
      strGroupToCheck = Split(strGroupShare, ";")(0)
      strDrive = Split(strGroupShare, ";")(1)
      If Right(strDrive, 1) <> ":" Then strDrive = strDrive & ":"
      strShare = Split(strGroupShare, ";")(2)
      If IsMemberOfGroup(objNetwork.UserDomain, objWinntUser, strGroupToCheck) = True Then
            'MsgBox "You are a member of " & strGroupToCheck
            If objFSO.DriveExists(strDrive) = True Then objNetwork.RemoveNetworkDrive strDrive, True, True
            objNetwork.MapNetworkDrive strDrive, strShare, True, True
      ElseIf IsMemberOfGroup(objNetwork.UserDomain, objWinntUser, strGroupToCheck) = False Then
            'MsgBox "You are NOT a member of " & strGroupToCheck
      ElseIf IsMemberOfGroup(objNetwork.UserDomain, objWinntUser, strGroupToCheck) = "Error" Then
            'MsgBox "There was no group found called " & strGroupToCheck
      End If      
Next
 
Function IsMemberOfGroup(strUserDomain, objUser, strGroup) 'the user is a member of a specified group
      IsMemberOfGroup = False
      Dim objGroup
      On Error Resume Next
      Set objGroup = GetObject("WinNT://" & strUserDomain & "/" & strGroup & ",group")
      If Err.Number Then
            IsMemberOfGroup = "Error"
      Else
            IsMemberOfGroup = objGroup.IsMember(objUser.ADsPath)
            'MsgBox objUser.ADsPath
      End If
End Function
'==============

Open in new window

0
Comment
Question by:vmamedov
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 12

Expert Comment

by:chandru_sol
ID: 20303168
Hi,

Try this......


regards
Chandru
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
 
Dim objNetwork
Set objNetwork = CreateObject("WScript.Network")
 
Dim objWinntUser
Set objWinntUser = GetObject("WinNT://" & objNetwork.UserDomain & "/" & objNetwork.UserName & ",user")
 
Dim strGroupToCheck, strGroupShare, strDrive, strShare
 
' Specity the group name, a semi-colon symbol, the drive letter, a semi-colon symbol, and the network share
arrGroupShares = Array( _
      "group1;Z;\\server\network\share1", _
      "group2;I;\\server\network\share2" _
      )
 
For Each strGroupShare In arrGroupShares
      strGroupToCheck = Split(strGroupShare, ";")(0)
      strDrive = Split(strGroupShare, ";")(1)
      If Right(strDrive, 1) <> ":" Then strDrive = strDrive & ":"
      strShare = Split(strGroupShare, ";")(2)
      If IsMemberOfGroup(objNetwork.UserDomain, objWinntUser, strGroupToCheck) = True Then
            'MsgBox "You are a member of " & strGroupToCheck
            If objFSO.DriveExists(strDrive) = True Then objNetwork.RemoveNetworkDrive strDrive, True
            objNetwork.MapNetworkDrive strDrive, strShare, True
      ElseIf IsMemberOfGroup(objNetwork.UserDomain, objWinntUser, strGroupToCheck) = False Then
            'MsgBox "You are NOT a member of " & strGroupToCheck
      ElseIf IsMemberOfGroup(objNetwork.UserDomain, objWinntUser, strGroupToCheck) = "Error" Then
            'MsgBox "There was no group found called " & strGroupToCheck
      End If      
Next
 
Function IsMemberOfGroup(strUserDomain, objUser, strGroup) 'the user is a member of a specified group
      IsMemberOfGroup = False
      Dim objGroup
      On Error Resume Next
      Set objGroup = GetObject("WinNT://" & strUserDomain & "/" & strGroup & ",group")
      If Err.Number Then
            IsMemberOfGroup = "Error"
      Else
            IsMemberOfGroup = objGroup.IsMember(objUser.ADsPath)
            'MsgBox objUser.ADsPath
      End If
End Function
'==============

Open in new window

0
 
LVL 12

Accepted Solution

by:
chandru_sol earned 500 total points
ID: 20303175
Whoops!

Change this line

If objFSO.DriveExists(strDrive) = True Then objNetwork.RemoveNetworkDrive strDrive, True

to

If objFSO.DriveExists(strDrive) = True Then objNetwork.RemoveNetworkDrive strDrive, True, True

regards
Chandru
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 20308788
Hi, I'm wondering if you've got some sort of cached credentials to a network resource....

Please follow the instructions in this article:
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/usercpl_manage_passwords.mspx

to check if you have any cached passwords, and remove those that are for the same resource as the server you are trying to map a drive to.....

Regards,

Rob.
0
 

Author Comment

by:vmamedov
ID: 20312432
thank you chandru/rob for all your help

chandru, your solution on a different post was it, it solved the problem
i have removed the 2nd true from adding network drives and it solved it, do i need to do the same for the removing of the drives???


rob, thank you for the original script and all the modifications that you have done

i will give full credit to chandru on this post and have already given full credit to rob on the other post that i have opened regarding the original script

again thanks for your help

if you both dont mind i have opened a another post regarding a different issue, if you can take a look at http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_22970085.html
0
 

Author Closing Comment

by:vmamedov
ID: 31409619
chandru was great and answered all my questions and his solution worked!!!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Script to copy or move mouse-selected collection of files plus targets referenced by shortcuts (.lnk) The purpose of this article is to help illuminate the real challenges and options available (where they may exist) for utilizing simple scriptin…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question