473,597 Members | 2,157 Online
Bytes | Software Development & Data Engineering Community
+ 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 5168
Hi Leo,

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

WNetAddConnecti on2
http://msdn.microsoft.com/library/de...us/wnet/wnet/w
netaddconnectio n2.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******@onlin e.microsoft.com > wrote in message
news:xK******** ******@cpmsftng xa07.phx.gbl...
Hi Leo,

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

WNetAddConnecti on2
http://msdn.microsoft.com/library/de...us/wnet/wnet/w netaddconnectio n2.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" -> "Administra tive 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******@onlin e.microsoft.com > wrote in message
news:if******** ******@cpmsftng xa07.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" -> "Administra tive 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.G etFiles(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******@onlin e.microsoft.com > wrote in message
news:if******** ******@cpmsftng xa07.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" -> "Administra tive 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******@onlin e.microsoft.com > wrote in message
news:XF******** ******@cpmsftng xa07.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******@onlin e.microsoft.com > wrote in message
news:XF******** ******@cpmsftng xa07.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
3086
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 add the iuser_<computer_name> profile into network computer that share it resources?
2
645
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 due to the integrated security model of .NET, bombs out with Security Exceptions when someone tries to run it off the network drive. Sure, I can go to the users PC, and via the control panel,
3
1612
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. Sample code is appreciated.
5
21554
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 folder on mapped network drive (eg. N:\Storage that corresponds to \\FS1NS\SharedDir\), I get an error as "Could not find part of path N:\".
1
1779
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 Windows (using XP), and they have “read” access only. My challenge is I need the application to have “write” access during certain functions, but I don’t want the user to have this access all the time. My intent is for the app to...
4
4658
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 and a desktop shortcut to the exe out on the network)... but is it really a good idea? What are some arguments for and against running a .NET Windows Forms client from a network share? Here is my initial list... I'd appreciate any additions,...
13
7063
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 with the mapped drive letter, but the drive letter refers to the drive mapping for the user that started the process, and cannot be resolved to a UNC path from a service running under LocalSystem. Presumably, therefore, I need to get the drive...
0
1462
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 user by using windows authentication screen. For example the WNetConnectionDialog shows the mapnetwork drive dialogbox.For example if you open an IE explorer and type the servername which you dont have access In the mean while I found...
10
11002
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 in C#. It doesnt seem like C$ would use MapNetworkDrive.
20
7074
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 where I can input \\path\folder, drive letter, and domain\user). Is this possible? If so, can someone point me in the right direction? Thank you, Brian Nicholson
0
7965
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
8271
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8380
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8258
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
5847
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 presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3881
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2399
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 we have to send another system
1
1493
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1231
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.