473,382 Members | 1,424 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

LogonUser

If I want to access the shared folder in other Windows PC, a popup dialog
will popup to input the username and password.

Is it possible to access the files in shared folder in coding without the
popup dialog if I have the user name and password in that host pc?

For examples, I want to open the file in a host, \\host\files\file.cpp,
fopen(\\\host\\files\file.cpp, 'r'); Is it possible? Should I use the
LogonUser() first?

Thanks.
Nov 16 '05 #1
8 2813
Yes , if \\host requires it , you should access the file under that user's
credentials.

"ZhangZQ" <zh*******@hotmail.com> wrote in message
news:#$**************@TK2MSFTNGP12.phx.gbl...
If I want to access the shared folder in other Windows PC, a popup dialog
will popup to input the username and password.

Is it possible to access the files in shared folder in coding without the
popup dialog if I have the user name and password in that host pc?

For examples, I want to open the file in a host, \\host\files\file.cpp,
fopen(\\\host\\files\file.cpp, 'r'); Is it possible? Should I use the
LogonUser() first?

Thanks.

Nov 16 '05 #2
yes, can you show me the example code to do that?
I want to know which functions should be used?

Thank you very much!
"pawar" <NoSpam@please> wrote in message
news:OE**************@TK2MSFTNGP11.phx.gbl...
Yes , if \\host requires it , you should access the file under that user's credentials.

"ZhangZQ" <zh*******@hotmail.com> wrote in message
news:#$**************@TK2MSFTNGP12.phx.gbl...
If I want to access the shared folder in other Windows PC, a popup dialog will popup to input the username and password.

Is it possible to access the files in shared folder in coding without the popup dialog if I have the user name and password in that host pc?

For examples, I want to open the file in a host, \\host\files\file.cpp,
fopen(\\\host\\files\file.cpp, 'r'); Is it possible? Should I use the
LogonUser() first?

Thanks.


Nov 16 '05 #3
"ZhangZQ" <zh*******@hotmail.com> wrote
If I want to access the shared folder in other Windows PC, a popup dialog
will popup to input the username and password.

Is it possible to access the files in shared folder in coding without the
popup dialog if I have the user name and password in that host pc?

For examples, I want to open the file in a host, \\host\files\file.cpp,
fopen(\\\host\\files\file.cpp, 'r'); Is it possible? Should I use the
LogonUser() first?


You don't have to do a LogonUser() unless the creditials are going to
conflict with what the process is running as.

You need to do WNetAddConnection2()

WNetAddConnection2(
"\\\\host\\files",
"password",
"username",
dwFlags
);

If you want it to prompt the user if the user/pass you give it fails set the
flags to CONNECT_INTERACTIVE.
Nov 16 '05 #4
Thank you, let me try.

"Chris P." <ms**@chrisnet.net> wrote in message
news:uA****************@TK2MSFTNGP09.phx.gbl...
"ZhangZQ" <zh*******@hotmail.com> wrote
If I want to access the shared folder in other Windows PC, a popup dialog will popup to input the username and password.

Is it possible to access the files in shared folder in coding without the popup dialog if I have the user name and password in that host pc?

For examples, I want to open the file in a host, \\host\files\file.cpp,
fopen(\\\host\\files\file.cpp, 'r'); Is it possible? Should I use the
LogonUser() first?
You don't have to do a LogonUser() unless the creditials are going to
conflict with what the process is running as.

You need to do WNetAddConnection2()

WNetAddConnection2(
"\\\\host\\files",
"password",
"username",
dwFlags
);

If you want it to prompt the user if the user/pass you give it fails set

the flags to CONNECT_INTERACTIVE.

Nov 16 '05 #5
Wait! I made a mixtake. The first parameter is the NETRESOURCE structure,
not just a path.

"ZhangZQ" <zh*******@hotmail.com> wrote
Thank you, let me try.

"Chris P." <ms**@chrisnet.net> wrote in message
news:uA****************@TK2MSFTNGP09.phx.gbl...
"ZhangZQ" <zh*******@hotmail.com> wrote
If I want to access the shared folder in other Windows PC, a popup dialog will popup to input the username and password.

Is it possible to access the files in shared folder in coding without the popup dialog if I have the user name and password in that host pc?

For examples, I want to open the file in a host, \\host\files\file.cpp, fopen(\\\host\\files\file.cpp, 'r'); Is it possible? Should I use the
LogonUser() first?


You don't have to do a LogonUser() unless the creditials are going to
conflict with what the process is running as.

You need to do WNetAddConnection2()

WNetAddConnection2(
"\\\\host\\files",
"password",
"username",
dwFlags
);

If you want it to prompt the user if the user/pass you give it fails set

the
flags to CONNECT_INTERACTIVE.


Nov 16 '05 #6

NETRESOURCE nr;
ZeroMemory(&nr,sizeof(NETRESOURCE));
nr.dwScope = RESOURCE_GLOBALNET;
nr.dwType = RESOURCETYPE_ANY;
nr.lpLocalName = "";
nr.lpRemoteName = (LPTSTR)"\\\\host\\files";
nr.lpProvider = NULL;
WNetAddConnection2(&nr,pszPass,pszUserName,NULL);
FILE* fp;
fp = fopen("\\\\host\\files\file.cpp", 'r');
Nov 16 '05 #7
it is good, it runs, thank you very much!

"childman" <ch******@163.com> wrote in message
news:Of**************@TK2MSFTNGP11.phx.gbl...

NETRESOURCE nr;
ZeroMemory(&nr,sizeof(NETRESOURCE));
nr.dwScope = RESOURCE_GLOBALNET;
nr.dwType = RESOURCETYPE_ANY;
nr.lpLocalName = "";
nr.lpRemoteName = (LPTSTR)"\\\\host\\files";
nr.lpProvider = NULL;
WNetAddConnection2(&nr,pszPass,pszUserName,NULL);
FILE* fp;
fp = fopen("\\\\host\\files\file.cpp", 'r');

Nov 16 '05 #8
If you need programmatically make share directory "files" use
NetShareAdd() for that
Arkady

"ZhangZQ" <zh*******@hotmail.com> wrote in message
news:#G**************@TK2MSFTNGP10.phx.gbl...
it is good, it runs, thank you very much!

"childman" <ch******@163.com> wrote in message
news:Of**************@TK2MSFTNGP11.phx.gbl...

NETRESOURCE nr;
ZeroMemory(&nr,sizeof(NETRESOURCE));
nr.dwScope = RESOURCE_GLOBALNET;
nr.dwType = RESOURCETYPE_ANY;
nr.lpLocalName = "";
nr.lpRemoteName = (LPTSTR)"\\\\host\\files";
nr.lpProvider = NULL;
WNetAddConnection2(&nr,pszPass,pszUserName,NULL);
FILE* fp;
fp = fopen("\\\\host\\files\file.cpp", 'r');


Nov 16 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Nimi | last post by:
When I run my application , the LogonUser method fails the exception is "LogonUser failed with error code :1314". I know the error is because of some privileges . I am using Windows 2000 sp4. I...
1
by: Rich | last post by:
I am running IIS6 on a Win2k3 server. I have an ASP.Net app (C#) that a user logs into and then I use LogonUser to validate them and log them onto the server. I have Windows Authentication ONLY...
3
by: Zeno Lee | last post by:
I'm trying to authenticate a user against a windows network. I want it to work across any kind of windows network from NT 4.0 up to Windows 2003 ADS. So far I've been using DirectoryEntry and...
3
by: Dan | last post by:
All, I am attempting to use the LogonUser API in an application. However, everytime I attempt to validate an account using this I get an error. The code is 1421 which has a description of...
2
by: BLiTZWiNG | last post by:
Having a few strage behaviours with this function, mainly in that when I try to logon to another computer with a different name/pass to the current user of the local machine, it tries to...
7
by: Jason | last post by:
I have an ASP.NET application with forms authentication. However, the login details correspond to a Windows account (I cannot use Windows authentication). If I obtain a token with LogonUser, can I...
3
by: plmanikandan | last post by:
Hi, i need to use logonuser api in c# for windows 2000. Logonuser api is working fine in windowsXp,Windows2003 server.in windows 2000 for running logonuser api we need SE_TCB_NAME ...
9
by: schaf | last post by:
Hi NG ! I used the examples on the internet to create a Impersonate class which allows me to log on as another user. After logged on as the new user I could access files on a remote computer,...
1
by: Sajid | last post by:
I use LogonUser for user authentication against AD. When I run this in XP is works fine. But it gives me a Win32 Error 1314 (ERROR_PRIVILEGE_NOT_HELD) in Win 2000. Any idea why and how do I solve...
6
by: nild | last post by:
Hello i have a strange problem. I'm using LogonUser to impersonate the user under which my program must run. On Win XP or Server 2003 it works. But on 2000 it doesn't. So i found out, to set...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.