Solved

The specified network password is not correct error during script execution

Posted on 2007-11-16
5
2,445 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In this article we want to have a look at the directory attributes which are used by Microsoft to store the so called Security Identifiers (SID). These SIDs plays an important role in delegating and granting permissions and in authentication of trus…
When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

895 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now