473,473 Members | 2,160 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Mapping a network share to a drive-letter at system-level

Hi,

Is it possible to create a network-drive at the SYSTEM-level? E.g.: map X:
to \\server1\share so a windows service can reach X: without having to log
on? I want a Windows .NET service to collect files from a UNIX-share (mapped
to X:) that is exposed to windows using Hummingbird-software.

Leo.
Jul 21 '05 #1
8 5148
Hi Leo,

As stated in another thread, you can use WNetAddConnection2() API whose
first parameter is NETRESOURCE structure. NETRESOURCE.lpLocalName field
points to a null-terminated string that specifies the name of a local
device to redirect, such as "X:".

WNetAddConnection2
http://msdn.microsoft.com/library/de...us/wnet/wnet/w
netaddconnection2.asp

Please feel free to let me know if you have any problems.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #2
Hi HuangTM,

Thanks for your reply. I posted a similar question in another thread and I
got your answer, which was exactly what I wanted at the time. The problem
however seems to be a little different now:

I use Hummingbird software (NFS) to connect e.g: X: to a UNIX-share. I can
only do this while being logged on (administrator).

When I run a service (localsystem), I can of course not 'see' the X-drive,
that is only available in my administrator logon-session.

The question is: can I create a connection in a administrator logon-session
that is available to a windows-service that runs under that same
administrator-account?

I don't think I can create this network connection from code, because I also
need the Hummingbird software to create the network connection.

Thanks in advance, Leo.

"Tian Min Huang" <ti******@online.microsoft.com> wrote in message
news:xK**************@cpmsftngxa07.phx.gbl...
Hi Leo,

As stated in another thread, you can use WNetAddConnection2() API whose
first parameter is NETRESOURCE structure. NETRESOURCE.lpLocalName field
points to a null-terminated string that specifies the name of a local
device to redirect, such as "X:".

WNetAddConnection2
http://msdn.microsoft.com/library/de...us/wnet/wnet/w netaddconnection2.asp

Please feel free to let me know if you have any problems.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #3
Hello Leo,

Thanks for your reply. Now I'd like to share the following information with
you:

1. We are able to configure a service to log on as a specific account
instead of the default Local System account by the following steps:

a. Go to "Control Panel" -> "Administrative Tools" -> "Services".
b. Right click the service and choose "Properties".
c. Go to "Log On" panel, click "This account" and input corresponding user
name and password.

2. You can also call the API LogonUser() to log a user on to the local
computer:
LogonUser
http://msdn.microsoft.com/library/de...us/security/se
curity/logonuser.asp

3. Since Hummingbird software (NFS) is a third-party tool, I suggest that
you can also contact the software vendor and see if there is any APIs
exposed for you to dynamically map a UNIX-share in your application/service.

Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #4
Thanks Tim,

I created a seperate service for the file-handling, which is running under
an account that has access to mapped-drives that are linked to the
UNIX-shares. It works fine now. The solution was much easier than I thought.
Thanks for your help.

Leo.

"Tian Min Huang" <ti******@online.microsoft.com> wrote in message
news:if**************@cpmsftngxa07.phx.gbl...
Hello Leo,

Thanks for your reply. Now I'd like to share the following information with you:

1. We are able to configure a service to log on as a specific account
instead of the default Local System account by the following steps:

a. Go to "Control Panel" -> "Administrative Tools" -> "Services".
b. Right click the service and choose "Properties".
c. Go to "Log On" panel, click "This account" and input corresponding user
name and password.

2. You can also call the API LogonUser() to log a user on to the local
computer:
LogonUser
http://msdn.microsoft.com/library/de...us/security/se curity/logonuser.asp

3. Since Hummingbird software (NFS) is a third-party tool, I suggest that
you can also contact the software vendor and see if there is any APIs
exposed for you to dynamically map a UNIX-share in your application/service.
Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #5
Hi Tim,

I'm still having trouble here. After changing the windows .NET service-logon
from localsystem to administrator, my routine in the service could reach the
network-drives. So I was happy!

However, the next time I started the service, again I couldn't reach the
network drives. The service runs under the administrator account and I've
double checked this by writing the WindowsIdentity.name to the system-log.

When the routine tries to get the files from the network-directory
(IO.Directory.GetFiles(path)) [where path is X:\test - which is perfectly
accessible when logging on as an administrator - X: mapped to \\server\c],
the catched error-message is: 'Could not find part of the path: "X:\test".
Even when I map X to a path on the local machine, I get the same error.

When I run this EXACT same routine from a stand-alone application (logging
on as administrator of course) everything works fine. I'm really puzzled
here. Am I missing something? Security issue? The routine is in a seperate
DLL that is called by the service / stand alone windows application.

Leo.

"Tian Min Huang" <ti******@online.microsoft.com> wrote in message
news:if**************@cpmsftngxa07.phx.gbl...
Hello Leo,

Thanks for your reply. Now I'd like to share the following information with you:

1. We are able to configure a service to log on as a specific account
instead of the default Local System account by the following steps:

a. Go to "Control Panel" -> "Administrative Tools" -> "Services".
b. Right click the service and choose "Properties".
c. Go to "Log On" panel, click "This account" and input corresponding user
name and password.

2. You can also call the API LogonUser() to log a user on to the local
computer:
LogonUser
http://msdn.microsoft.com/library/de...us/security/se curity/logonuser.asp

3. Since Hummingbird software (NFS) is a third-party tool, I suggest that
you can also contact the software vendor and see if there is any APIs
exposed for you to dynamically map a UNIX-share in your application/service.
Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #6
Hello Leo,

Thanks for your informtion. I am not familiar with Hummingbird software
(NFS), still I believe the following issue you may take into consideration:

The timing of Hummingbird software (NFS) restore the connection. Generally
speaking, when we configure a service to log on as a specific account,
Windows only ensures the service run as the account's preveliges you
specified and will not restore the network connection. While we manually
log on the Windows system, it will create a visible Window Station and
initialize the Desktop that will map the corresponding network share. After
manually logging on as Administator account, you can stop/restart the
service and see if it can access the network share then.

To work around this problem, I strongly recommend you contact Hummingbird
Software and check if there is any APIs or command that you can call from
within your service to create a network connection to a UNIX-share.

Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #7
Thanks Tim,

I'll follow your advice and contact Hummingbird. It seems to be the best
option for now.

Leo.

"Tian Min Huang" <ti******@online.microsoft.com> wrote in message
news:XF**************@cpmsftngxa07.phx.gbl...
Hello Leo,

Thanks for your informtion. I am not familiar with Hummingbird software
(NFS), still I believe the following issue you may take into consideration:
The timing of Hummingbird software (NFS) restore the connection. Generally
speaking, when we configure a service to log on as a specific account,
Windows only ensures the service run as the account's preveliges you
specified and will not restore the network connection. While we manually
log on the Windows system, it will create a visible Window Station and
initialize the Desktop that will map the corresponding network share. After manually logging on as Administator account, you can stop/restart the
service and see if it can access the network share then.

To work around this problem, I strongly recommend you contact Hummingbird
Software and check if there is any APIs or command that you can call from
within your service to create a network connection to a UNIX-share.

Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #8
Thanks Tim,

I'll follow your advice and contact Hummingbird. It seems to be the best
option for now.

Leo.

"Tian Min Huang" <ti******@online.microsoft.com> wrote in message
news:XF**************@cpmsftngxa07.phx.gbl...
Hello Leo,

Thanks for your informtion. I am not familiar with Hummingbird software
(NFS), still I believe the following issue you may take into consideration:
The timing of Hummingbird software (NFS) restore the connection. Generally
speaking, when we configure a service to log on as a specific account,
Windows only ensures the service run as the account's preveliges you
specified and will not restore the network connection. While we manually
log on the Windows system, it will create a visible Window Station and
initialize the Desktop that will map the corresponding network share. After manually logging on as Administator account, you can stop/restart the
service and see if it can access the network share then.

To work around this problem, I strongly recommend you contact Hummingbird
Software and check if there is any APIs or command that you can call from
within your service to create a network connection to a UNIX-share.

Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #9

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

Similar topics

1
by: Serge | last post by:
Hi, i would map a network drive from a share on another server. it works fine with the net use command under user login but it do not work from an asp script or dll. is this that i have to...
2
by: MF | last post by:
In visual basic 6 I can write an application and toss it up on a shared network drive for the company to access. Works like a champ. In .NET my C# application runs fine on anyones machine, but...
3
by: Chris Fink | last post by:
Hi, Attempting to determine if a drive mapping is present, and if it is not, want to connect it. Anyone familiar with the .net classes that I would use to accomplish this? Thanks in advance....
5
by: Niloday | last post by:
Hi All, I am trying to access a mapped network drive from a service that I have created. The service needs to create/delete folders/files on a network drive. When I tried to connect to a...
1
by: Shallotx | last post by:
I am working on a database imaging application. Links to the images are stored in the database and accessed via a shared network drive. This network share is mapped when the user logs on to...
4
by: Jeremy S. | last post by:
We're in the process of writing a new Windows Forms app and the desktop support folks want for it to be run from a network share. I know it's possible (i.e., just have the framework on the clients...
13
by: =?Utf-8?B?RGF2ZQ==?= | last post by:
I am actually trying to get the UNC path of the main module of a process running from a mapped drive, and I am trying to do this from a service. The ProcessModule class only provides the full path...
0
by: danasegarane | last post by:
Hi all I want to map a network drive. If the user has access to that site then that path will map automatically. If the user doesnt have any rights the i need to get the username and pwd from the...
10
by: =?Utf-8?B?Z3JlYXRiYXJyaWVyODY=?= | last post by:
Sorry about that previous one. I pressed enter too early. How does one go about mapping a network drive in C#. i know you use MapNetworkDrive in scripting languages, but i'm not sure how to do it...
20
by: =?Utf-8?B?QnJpYW4gTmljaG9sc29u?= | last post by:
Hello, I'm trying to create an admin page that can run miscellaneous scripts for our IT department. Currently, I'm trying to create a script that can map a network drive for a user (e.g. a form...
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
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...
1
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
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 project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.