Shared Folders With Username/Password
-
Hey all. I've got a tiny helper application that I've built that creates text files on a network/shared drive. I'm presently just using CStdioFile to create the text files. The problem that I am running into is username/password authentication. I don't really know where to start for this and would appreciate some pointers in the right direction. The network/shared drive is "\\S-CPU1\c\the_folder". If I open up IE, and go to \\S-CPU1\c\the_folder ... the first time I try it, IE asks for the username/password. I enter it in, it goes there. I can then close out of IE and it "remembers" the username/password combination (or keeps me logged in to it, or whatever) until I physically LOG OUT or switch users. So, if I do that one time, I can then run my helper app, and it creates the files over on that shared folder without a problem. The problem is I would like to automate this, so that I/the user does not have to first bring up IE and go through that process (and I don't want to physically MAP a drive to that folder). I would like to be able to run my app, and if it realizes that it needs a user/password to access that folder, it will go ahead and bring up a prompt asking the user for that information. After that point, it'll just roll through and do it's thing. I've searched for several phrases in the articles on this site, but can not seem to find anything that is doing what I want. If someone could point me in the right direction, I would greatly appreciate it. Shultas
-
Hey all. I've got a tiny helper application that I've built that creates text files on a network/shared drive. I'm presently just using CStdioFile to create the text files. The problem that I am running into is username/password authentication. I don't really know where to start for this and would appreciate some pointers in the right direction. The network/shared drive is "\\S-CPU1\c\the_folder". If I open up IE, and go to \\S-CPU1\c\the_folder ... the first time I try it, IE asks for the username/password. I enter it in, it goes there. I can then close out of IE and it "remembers" the username/password combination (or keeps me logged in to it, or whatever) until I physically LOG OUT or switch users. So, if I do that one time, I can then run my helper app, and it creates the files over on that shared folder without a problem. The problem is I would like to automate this, so that I/the user does not have to first bring up IE and go through that process (and I don't want to physically MAP a drive to that folder). I would like to be able to run my app, and if it realizes that it needs a user/password to access that folder, it will go ahead and bring up a prompt asking the user for that information. After that point, it'll just roll through and do it's thing. I've searched for several phrases in the articles on this site, but can not seem to find anything that is doing what I want. If someone could point me in the right direction, I would greatly appreciate it. Shultas
DWORD WNetAddConnection2( LPNETRESOURCE lpNetResource, // connection details LPCTSTR lpPassword, // password LPCTSTR lpUsername, // user name DWORD dwFlags // connection options ); lpLocalName :Points to a null-terminated string that specifies the name of a local device to redirect, such as "F:" or "LPT1". The string is treated in a case-insensitive manner. If the string is empty, or if lpLocalName is NULL, the function makes a connection to the network resource without redirecting a local device.