473,465 Members | 1,419 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

FileIO Netwk Permissions!

Hi All, How do I access a shared Drive which requires username and password
to access?
I need to write a file in a folder within it

TIA
Dec 2 '05 #1
8 1342
Vai2000,

What you want to do is call the LogonUser API function, logging in with
the user's credentials that you want to impersonate. Then, you will call
the Impersonate method on the WindowsIdentity class, passing the user token
to be impersonated.

You can then make your call, and it will be under that other user's
account. Mind you, you need to be careful about these credentials being
embedded in your app.

Check out the documentation for the Impersonate method on the
WindowsIdentity class (the overload that takes an IntPtr parameter) for a
code example.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Vai2000" <no****@microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi All, How do I access a shared Drive which requires username and
password
to access?
I need to write a file in a folder within it

TIA

Dec 2 '05 #2
Thanks, what if the server is not a part of any Domain its a standalone?

TIA

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:uf****************@TK2MSFTNGP14.phx.gbl...
Vai2000,

What you want to do is call the LogonUser API function, logging in with the user's credentials that you want to impersonate. Then, you will call
the Impersonate method on the WindowsIdentity class, passing the user token to be impersonated.

You can then make your call, and it will be under that other user's
account. Mind you, you need to be careful about these credentials being
embedded in your app.

Check out the documentation for the Impersonate method on the
WindowsIdentity class (the overload that takes an IntPtr parameter) for a
code example.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Vai2000" <no****@microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi All, How do I access a shared Drive which requires username and
password
to access?
I need to write a file in a folder within it

TIA


Dec 2 '05 #3
LogonUser will still work in that case.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Vai2000" <no****@microsoft.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Thanks, what if the server is not a part of any Domain its a standalone?

TIA

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in
message news:uf****************@TK2MSFTNGP14.phx.gbl...
Vai2000,

What you want to do is call the LogonUser API function, logging in

with
the user's credentials that you want to impersonate. Then, you will call
the Impersonate method on the WindowsIdentity class, passing the user

token
to be impersonated.

You can then make your call, and it will be under that other user's
account. Mind you, you need to be careful about these credentials being
embedded in your app.

Check out the documentation for the Impersonate method on the
WindowsIdentity class (the overload that takes an IntPtr parameter) for a
code example.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Vai2000" <no****@microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
> Hi All, How do I access a shared Drive which requires username and
> password
> to access?
> I need to write a file in a folder within it
>
> TIA
>
>



Dec 2 '05 #4
Thanks Nick,
"The LogonUser function attempts to log a user on to the local computer. The
local computer is the computer from which LogonUser was called. You cannot
use LogonUser to log on to a remote computer."

I want to log the user on the Remote Computer!
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2****************@tk2msftngp13.phx.gbl...
LogonUser will still work in that case.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Vai2000" <no****@microsoft.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Thanks, what if the server is not a part of any Domain its a standalone?

TIA

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in
message news:uf****************@TK2MSFTNGP14.phx.gbl...
Vai2000,

What you want to do is call the LogonUser API function, logging in

with
the user's credentials that you want to impersonate. Then, you will call the Impersonate method on the WindowsIdentity class, passing the user

token
to be impersonated.

You can then make your call, and it will be under that other user's
account. Mind you, you need to be careful about these credentials being embedded in your app.

Check out the documentation for the Impersonate method on the
WindowsIdentity class (the overload that takes an IntPtr parameter) for a code example.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Vai2000" <no****@microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
> Hi All, How do I access a shared Drive which requires username and
> password
> to access?
> I need to write a file in a folder within it
>
> TIA
>
>



Dec 2 '05 #5

"Vai2000" <no****@microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi All, How do I access a shared Drive which requires username and
password
to access?
I need to write a file in a folder within it

TIA


Don't do this from code, just map the remote share to the users logon
session by running the "net use passwd /USER:machinename\username" command
from the command line or a logon script.

Willy.


Dec 2 '05 #6
LogonUser is not meant to "logon", it's used to obtain an Access Token that
can be used to impersonate a specific user account.
When you need to access a resource on a remote server, just specify the
remote machine name as domain argument and a vailid user and password as
registered in the remote servers security DB.
Only problem with LogonUser is that you need TCB privileges (part of OS
privilege) when running on W2K.

Willy.

"Vai2000" <no****@microsoft.com> wrote in message
news:eL**************@TK2MSFTNGP15.phx.gbl...
Thanks Nick,
"The LogonUser function attempts to log a user on to the local computer.
The
local computer is the computer from which LogonUser was called. You cannot
use LogonUser to log on to a remote computer."

I want to log the user on the Remote Computer!
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in
message news:%2****************@tk2msftngp13.phx.gbl...
LogonUser will still work in that case.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Vai2000" <no****@microsoft.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
> Thanks, what if the server is not a part of any Domain its a
> standalone?
>
> TIA
>
> "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com>
> wrote
> in
> message news:uf****************@TK2MSFTNGP14.phx.gbl...
>> Vai2000,
>>
>> What you want to do is call the LogonUser API function, logging in
> with
>> the user's credentials that you want to impersonate. Then, you will call >> the Impersonate method on the WindowsIdentity class, passing the user
> token
>> to be impersonated.
>>
>> You can then make your call, and it will be under that other
>> user's
>> account. Mind you, you need to be careful about these credentials being >> embedded in your app.
>>
>> Check out the documentation for the Impersonate method on the
>> WindowsIdentity class (the overload that takes an IntPtr parameter)
>> for a >> code example.
>>
>> Hope this helps.
>>
>>
>> --
>> - Nicholas Paldino [.NET/C# MVP]
>> - mv*@spam.guard.caspershouse.com
>>
>> "Vai2000" <no****@microsoft.com> wrote in message
>> news:%2****************@TK2MSFTNGP14.phx.gbl...
>> > Hi All, How do I access a shared Drive which requires username and
>> > password
>> > to access?
>> > I need to write a file in a folder within it
>> >
>> > TIA
>> >
>> >
>>
>>
>
>



Dec 2 '05 #7
Yes I did net use to map the network drive and provided the credentials,
though my Application fails to access the same, it fails to really now what
Z: Drive is (I used this drive letter to map the remote computer folder)

"Willy Denoyette [MVP]" <wi*************@telenet.be> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...

"Vai2000" <no****@microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi All, How do I access a shared Drive which requires username and
password
to access?
I need to write a file in a folder within it

TIA


Don't do this from code, just map the remote share to the users logon
session by running the "net use passwd /USER:machinename\username" command
from the command line or a logon script.

Willy.


Dec 3 '05 #8
What kind of application is it?

Willy.

"Vai2000" <no****@microsoft.com> wrote in message
news:u3**************@TK2MSFTNGP12.phx.gbl...
Yes I did net use to map the network drive and provided the credentials,
though my Application fails to access the same, it fails to really now
what Z: Drive is (I used this drive letter to map the remote computer
folder)

"Willy Denoyette [MVP]" <wi*************@telenet.be> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...

"Vai2000" <no****@microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi All, How do I access a shared Drive which requires username and
password
to access?
I need to write a file in a folder within it

TIA


Don't do this from code, just map the remote share to the users logon
session by running the "net use passwd /USER:machinename\username"
command from the command line or a logon script.

Willy.



Dec 3 '05 #9

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

Similar topics

1
by: Brad H McCollum | last post by:
I'm writing an application using VB 6.0 as the front-end GUI, and the MSDE version of SQL Server as the back-end (it's a program for a really small # of users --- less then 3-4). I'm trying to...
6
by: !!! Klutzo !!! | last post by:
I give permissions for ASPNET on a top level subdirectory. A windows program copies a file into the subdirectory, however, my web service cannot access the file because it does not have...
1
by: Moe | last post by:
I have a winForm control that contains an openFileDialog. I am using this control in a webForm by enbedding it using an <object> tag. I need to access some information about the file on the client....
0
by: Steven Smith | last post by:
Hi guy's I've hit a bit of a sticking point, I'm sure this is simple enough but I just can't get my head around it and I'm looking for a bit of direction. When dealing with FileIO up until now I...
3
by: Marquis | last post by:
I am writing a ActiveX dll using Visual C# However , i am facing fileio and environment permission problem. Is there any way to solve this problem? just as signing the dll or other method to...
13
by: MLH | last post by:
Invalid qualifier error displays at compile time on this A97 example from Permissions Property HELP. What's wrong with the strContainerName assignment line? (6th line) Sub...
0
by: Curt K | last post by:
We run some web services (IIS 5 and IIS 6) that communicate to a COM out of process server, which in turn communicates to another out of process COM server (long story). We have had lots of...
8
by: jporter188 | last post by:
Hello, I am working on a project to manipulate XML files. All of the files, the code, and the output are on network drives. When I run my program I get an exception (see below). I tried giving...
0
by: =?Utf-8?B?bWFnZWxsYW4=?= | last post by:
Hi All, I have the following: FileIO.FileSystem.CopyDirectory(strFromString, strLocString, FileIO.UIOption.AllDialogs) Q: How do I access the UI that is presented and re-positon the x,y...
1
by: =?Utf-8?B?bWFnZWxsYW4=?= | last post by:
hi all, I have a button (stopcopy) that I want the user to cancel out of a long file copying operation. I'm not clear what I should "adding" in the sub to make this happen besides & return....
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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: 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 ...

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.