473,406 Members | 2,312 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,406 software developers and data experts.

Accessing LAN from the page through Web Service

JP
Hi,

I want to import a few Excel Sheets from a network drive
(e.g. F:\, some file server). The way it works right now
is I have a 'File Watcher' that picks up the files as soon
as they are available and dumps them into the Web Server
and then the Web Service 'File Importer' on the same Web
Server imports them into the database.

I would like to trigger the import with a 'Click' event
and without the 'File Watcher' moving the files into the
Web Server. The problem I am having with this is to supply
the credentials from the 'Click' event and connect to that
network drive (F:\, the file server) through the Web
Server using the Web Service 'File Importer'.

How do I connect to this network drive through the Web
Service by supplying the credentials from the web page?

Thanks in advance!
Regards,
JP

Nov 17 '05 #1
1 1132
I've used this (complete code) and it works well for this sort of thing. It
maps a null drive to \\server\ipc$ hope this helps..

using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential)]
public struct NETRESOURCEA
{
public int dwScope;
public int dwType;
public int dwDisplayType;
public int dwUsage;
[ MarshalAs (UnmanagedType.LPStr)]
public string lpLocalName;
[ MarshalAs (UnmanagedType.LPStr)]
public string lpRemoteName;
[ MarshalAs (UnmanagedType.LPStr)]
public string lpComment;
[ MarshalAs (UnmanagedType.LPStr)]
public string lpProvider;
public override String ToString()
{
String str = "LocalName: " + lpLocalName + " RemoteName: " + lpRemoteName
+ " Comment: " + lpComment + " lpProvider: " + lpProvider;
return(str);
}
}

class Authentication
{
[DllImport("mpr.dll")]
private static extern int WNetAddConnection2A(
[MarshalAs(UnmanagedType.LPArray)] NETRESOURCEA[] lpNetResource,
[MarshalAs(UnmanagedType.LPStr)] string lpPassword,
[MarshalAs(UnmanagedType.LPStr)] string UserName,
int dwFlags);
[DllImport("mpr.dll")]
private static extern int WNetCancelConnection2(
[MarshalAs(UnmanagedType.LPStr)] string lpName,
int dwFlags,
bool fForce);

public static int ValidateUser(string Server,string User,string Password)
{
NETRESOURCEA [] n = new NETRESOURCEA[1];
n[0] = new NETRESOURCEA();
n[0].dwType = 0;
int dwFlags = 1;
n[0].lpLocalName = null;
n[0].lpRemoteName = @"\\" + Server + @"\IPC$";
n[0].lpProvider = null;

int res = WNetAddConnection2A( n, Password, User, dwFlags );
return res;
}
public static void CancelConnection(string Connection)
{
WNetCancelConnection2(Connection, 0, true);
}
}

"JP" <jp*****@hotmail.com> wrote in message
news:0c****************************@phx.gbl...
Hi,

I want to import a few Excel Sheets from a network drive
(e.g. F:\, some file server). The way it works right now
is I have a 'File Watcher' that picks up the files as soon
as they are available and dumps them into the Web Server
and then the Web Service 'File Importer' on the same Web
Server imports them into the database.

I would like to trigger the import with a 'Click' event
and without the 'File Watcher' moving the files into the
Web Server. The problem I am having with this is to supply
the credentials from the 'Click' event and connect to that
network drive (F:\, the file server) through the Web
Server using the Web Service 'File Importer'.

How do I connect to this network drive through the Web
Service by supplying the credentials from the web page?

Thanks in advance!
Regards,
JP

Nov 17 '05 #2

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

Similar topics

1
by: pronto | last post by:
Hi guys. I made Web Service (C#) and running it on my localhost (Win2000). It does work from IE and from C# client application. Now I'm trying to create application with Visual C++ 6 and get...
2
by: hazz | last post by:
I don't get it. I have a VS2005 solution with a web service project and a windows project. The web service when tested on its own works fine. But when I add it as a web reference and refer to it my...
0
by: George | last post by:
Hello, I'm running an ASPX application "WebApplication1" which consumes a web service (service1.asmx) hosted on a machine with IP (128.1.7.x) . The web service is located in the intranet. The...
3
by: Khalique | last post by:
Problem: Accessing web service causes exception – “The request failed with HTTP status 401 : Access Denied”. I created a web service on my local machine and then developed a separate test...
10
by: amazon | last post by:
Our vender provided us a web service: 1xyztest.xsd file... ------------------------------------ postEvent PostEventRequest ------------------------------------- authetication authentication...
3
by: Brad | last post by:
I'm setting up my new pc with all my VS.net projects and I'm missing something.....something I've done many times before without problem. I have several asp.net apps accessing secure .net web...
0
by: jacorona | last post by:
Hello all, I have found a problem accesing a web service hosted in IIS 5.0 in a W2K box. The web service site is configured to accept both integrated windows authentication and client certificates....
1
by: =?Utf-8?B?Tmljaw==?= | last post by:
Hello, I hope I'm hoping posting this in the correct place. I've got an asmx web service and another guy created a client app that we distribute to customers. We seem to be having some trouble...
10
by: Ben | last post by:
I'm trying to access a c# web service from a web form. I set up the web reference proxy object as follows: proxy.PreAuthenticate = true; proxy.Credentials = CredentialCache.DefaultCredentials;...
1
by: =?Utf-8?B?VmljdG9y?= | last post by:
Hi, I'm trying to add web reference to my project and getting back following message: "There was an error downloading 'https://webservicestest.com/services/SubscriptionService/v1/'. Unable to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.