[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

WNetAddConnect & /user:domain\username

Posted on 1998-06-11
2
Medium Priority
?
223 Views
Last Modified: 2008-02-01
Does anyone know how to specify the username and domain for the
WNetAddConnection2 call (or other API)?

For example:

NetR.dwScope = RESOURCE_GLOBALNET
NetR.dwType = RESOURCETYPE_DISK
NetR.dwDisplayType = RESOURCEDISPLAYTYPE_SHARE
NetR.dwUsage = RESOURCEUSAGE_CONNECTABLE
NetR.lpLocalName = "G:"
NetR.lpRemoteName = "\\share"
WNetAddConnection2(NetR, "pass", NULL, CONNECT_UPDATE_PROFILE)

This would be the same as net use G: \\SERVER\share pass
This is fine under 95/98.


But under NT4, I need to specify the domain & username such as

net use G: \\SERVER\share /user:domain\username pass

How do I do this with VB code?  Is there something else other then
WNetAddConnection2 that can do it?

Please help!
0
Comment
Question by:scottg
[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 Comments
 
LVL 6

Accepted Solution

by:
alamo earned 1200 total points
ID: 1463170
The third argument to WNetAddConnection2, which you have set to NULL, is the username.

Good luck!
0
 
LVL 6

Expert Comment

by:alamo
ID: 1463171
I just tried this in a test program, and confirmed that it works.

The one thing I couldn't test is how it processes the "domain\" part of "domain\user". The only machine I have available to test with at the moment is in the same domain as I am, and the connection would succeed even if I put the wrong domain. I am assuming that was because it was trying the default domain when the ine I specified one failed, but I can't prove that. Let me know if you have problems with the domain part, and I will investigate further.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

649 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