-
March 28th, 2017, 12:52 PM
#1
WNetAddConnection2 - Crzy
Hi guys
I've been problem with WNetAddConnection2 if i don't inform nr.lpProvider= NULL; Windows API return invalid password. Why???
Look below my code
Original code:
Code:
nr.dwScope=RESOURCE_GLOBALNET;
nr.dwUsage=RESOURCEUSAGE_CONNECTABLE;
nr.dwType=RESOURCETYPE_ANY;
nr.lpLocalName=NULL;
nr.lpRemoteName="\\\\MyComp10";
nr.lpProvider=NULL;
net=WNetAddConnection2(&nr,"password","Administrator",CONNECT_UPDATE_PROFILE);
In this case, with nr.lpProvider=NULL WNetAddConnection2 return invalid password.
New code:
Code:
nr.dwScope=RESOURCE_GLOBALNET;
nr.dwUsage=RESOURCEUSAGE_CONNECTABLE;
nr.dwType=RESOURCETYPE_ANY;
nr.lpLocalName=NULL;
nr.lpRemoteName="\\\\MyComp10";
nr.lpProvider="Developer";
net=WNetAddConnection2(&nr,"password","Administrator",CONNECT_UPDATE_PROFILE);
In this case, when informed lpProvider, it is ok, no error. Why??
The more curious is that the problem occurs in only a few workstations. What is going on?
Thank's
Last edited by 2kaud; March 28th, 2017 at 12:56 PM.
Reason: Added code tags
-
March 28th, 2017, 01:04 PM
#2
Re: WNetAddConnection2 - Crzy
The more curious is that the problem occurs in only a few workstations.
What is WNetGetProviderName() https://msdn.microsoft.com/en-us/lib...(v=vs.85).aspx returning for lpProviderName?
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
March 28th, 2017, 01:41 PM
#3
Re: WNetAddConnection2 - Crzy
When i used WNetGetProviderName(), return the same name of lpProvider.
I made one test in Windows console (command prompt) and the problem occur as well. Look below:
net use p: \\MyComp10\xml /usereveloper\Administrator <ENTER>
Enter password: password
It's ok.
net use p: \\MyComp10\xml /user:Administrator <ENTER>
Enter password: password
Error invalid password
The problem occur in command line as well. Windows BUG???
Thank's
-
March 28th, 2017, 02:53 PM
#4
Re: WNetAddConnection2 - Crzy
Originally Posted by ejunior
...
The problem occur in command line as well. Windows BUG???
If you are so sure - try to file it in https://connect.microsoft.com/
Victor Nijegorodov
-
March 28th, 2017, 03:33 PM
#5
Re: WNetAddConnection2 - Crzy
For developer\Administrator, is developer an OU within AD?
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
March 28th, 2017, 03:40 PM
#6
Re: WNetAddConnection2 - Crzy
"Developer" is my Domain Controller
"Administrator" is my Domain Administrator user
-
March 28th, 2017, 03:51 PM
#7
Re: WNetAddConnection2 - Crzy
and under what credentials are you trying to use net use? Is \\mycomp10 computer part of the same domain?
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
March 28th, 2017, 03:58 PM
#8
Re: WNetAddConnection2 - Crzy
Yes \\Mycomp10 is part of the same domain.
Domain - Windows 2012
Mycomp10 - Windows 7
-
March 28th, 2017, 04:17 PM
#9
Re: WNetAddConnection2 - Crzy
net use p: \\MyComp10\xml /user : Developer\Administrator
This uses account administrator on DC Developer to authenticate to \\MyComp10 (the domain administrator account). As \\MyComp10 is part of the domain with correct group membership etc then this is fine.
net use p: \\MyComp10\xml /user:Administrator
This uses account Administrator on \\MyComp10 to authenticate (the local adminstrator). If the password for the local Administrator account is different to that of the domain administrator account then the authentication will fail with invalid password. This only occurs on those few workstations where the password for the local administrator account is different to that of the domain administrator account. Note that it is good practice for the local and domain administrator accounts to have different passwords.
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
March 28th, 2017, 06:14 PM
#10
Re: WNetAddConnection2 - Crzy
2kuad,
I agree with you about best practice for domain administrator accounts and local admins in workstation, but in this post "Administrator" is only example name. I have a specific user to execute this operation. The name is SVC.Net-map and have power to maping network e copy files.
This user exists only in my DC (AD). This is so strange, because I have 10 machines in the domain and three of them do the mapping (net use p: \\MyComp10\xml /user:SVC.Net-map) without complaining of invalid password, but the other seven do not. So crazy....
Thank's
-
March 29th, 2017, 04:45 AM
#11
Re: WNetAddConnection2 - Crzy
I would be looking closely at how the computers are actually members of the AD domain. Is all the DNS, domain membership, group membership etc correct - and what is different between those that work and those that don't.
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|