473,706 Members | 3,816 Online
Bytes | Software Development & Data Engineering Community
+ 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 1354
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.co m

"Vai2000" <no****@microso ft.com> wrote in message
news:%2******** ********@TK2MSF TNGP14.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.c om> wrote in
message news:uf******** ********@TK2MSF TNGP14.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.co m

"Vai2000" <no****@microso ft.com> wrote in message
news:%2******** ********@TK2MSF TNGP14.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.co m

"Vai2000" <no****@microso ft.com> wrote in message
news:%2******** ********@tk2msf tngp13.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.c om> wrote
in
message news:uf******** ********@TK2MSF TNGP14.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.co m

"Vai2000" <no****@microso ft.com> wrote in message
news:%2******** ********@TK2MSF TNGP14.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.c om> wrote in
message news:%2******** ********@tk2msf tngp13.phx.gbl. ..
LogonUser will still work in that case.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Vai2000" <no****@microso ft.com> wrote in message
news:%2******** ********@tk2msf tngp13.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.c om> wrote
in
message news:uf******** ********@TK2MSF TNGP14.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.co m

"Vai2000" <no****@microso ft.com> wrote in message
news:%2******** ********@TK2MSF TNGP14.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****@microso ft.com> wrote in message
news:%2******** ********@TK2MSF TNGP14.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:machinenam e\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****@microso ft.com> wrote in message
news:eL******** ******@TK2MSFTN GP15.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.c om> wrote
in
message news:%2******** ********@tk2msf tngp13.phx.gbl. ..
LogonUser will still work in that case.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Vai2000" <no****@microso ft.com> wrote in message
news:%2******** ********@tk2msf tngp13.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.c om>
> wrote
> in
> message news:uf******** ********@TK2MSF TNGP14.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.co m
>>
>> "Vai2000" <no****@microso ft.com> wrote in message
>> news:%2******** ********@TK2MSF TNGP14.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******** ********@TK2MSF TNGP14.phx.gbl. ..

"Vai2000" <no****@microso ft.com> wrote in message
news:%2******** ********@TK2MSF TNGP14.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:machinenam e\username" command
from the command line or a logon script.

Willy.


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

Willy.

"Vai2000" <no****@microso ft.com> wrote in message
news:u3******** ******@TK2MSFTN GP12.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******** ********@TK2MSF TNGP14.phx.gbl. ..

"Vai2000" <no****@microso ft.com> wrote in message
news:%2******** ********@TK2MSF TNGP14.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:machinenam e\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
3068
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 determine, through the Visual Basic interface, the permissions of each user that's using the application on his/her machine. For example, let's say I'm user "Michael" that's sitting down at my machine using the app. I've written. The security...
6
2277
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 permissions. Shouldn't the file automatically inherit permissions by being dropped into that top level subdirectory?
1
2103
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. I strongly named my control assembly . I created a machine level permission set, and assigned FileDialog, FileIO and User interface permission. I created a code group under all_Code, associated my assembly's strong name to that group and...
0
944
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 would have created a user- defined data structure to store my data from which I could load / save to a Random Access Text File via textboxes etc on the form. However the problem I'm now facing is twofold. firstly:
3
2238
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 grant the permission? Thanks, Marquis
13
1710
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 SetDocPermissions(docUnknown As Document) Dim strContainerName As String ' Set UserName property to valid existing group account. docUnknown.UserName = "Marketers" ' Get value of Container property. strContainerName = docUnknown.Container.Name
0
1349
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 permissions issues getting the web service to communicate to the COM object to the point that we use the "administrator" account (yes, I know this is really bad). We need to tidy this for security purposes and to run under Vista and properly set up...
8
7705
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 the LocalIntranet_Zone full permissions in the .NET Framework 2.0 Configuration msc. This had no effect whatsoever. What do I need to do to fix this? Thanks,
0
2030
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 location..?
1
2588
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. I want to stop/cancel the file io operation and return back to the calling form.
0
8695
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9155
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...
1
9049
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8989
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...
0
7901
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5938
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4708
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2499
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2092
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.