Click here to Skip to main content
16,011,374 members
Home / Discussions / C#
   

C#

 
GeneralJournal Hook Pin
lajiyo3-Dec-03 22:18
lajiyo3-Dec-03 22:18 
GeneralHide Commandbars in word doc shown in axWebBrowser... Pin
Martin Jonsson3-Dec-03 20:02
Martin Jonsson3-Dec-03 20:02 
GeneralRe: Hide Commandbars in word doc shown in axWebBrowser... Pin
Heath Stewart4-Dec-03 4:53
protectorHeath Stewart4-Dec-03 4:53 
GeneralC# Threads Pin
Anonymous3-Dec-03 19:35
Anonymous3-Dec-03 19:35 
GeneralRe: C# Threads Pin
Anonymous4-Dec-03 2:16
Anonymous4-Dec-03 2:16 
GeneralRe: C# Threads Pin
Heath Stewart4-Dec-03 4:40
protectorHeath Stewart4-Dec-03 4:40 
GeneralCopy files across networked servers Pin
stateyama3-Dec-03 14:11
stateyama3-Dec-03 14:11 
GeneralRe: Copy files across networked servers Pin
Heath Stewart4-Dec-03 4:37
protectorHeath Stewart4-Dec-03 4:37 
Actually - in a domain setup - the user account doesn't exist on different computers (except, perhaps, different DCs that either cache or backup accounts). That's only a low-grade workgroup trick or for local users.

To accomplish what you want, you have to program the prompt yourself and deal with impersonation (which may cause problems on the local end if the impersonated user doesn't have access to the source resource). The fact is that .NET is a basic framework and doesn't include all functionality in Windows.

First, attempt a File.Copy. If you get an UnauthorizedAccessException, show a modal dialog to get the username and password (of course, mask the password using the TextBox.PasswordChar property). Then you're going to want to impersonate the requested user account. See the SDK documentation for WindowsIdentity.Impersonate for details and very good example source (P/Invoking native functions is required in .NET 1.x at least). Finally, perform the File.Copy again, and undo and close the impersonation handles (this is covered in the sample source I mentioned).

 

-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
GeneralRe: Copy files across networked servers Pin
stateyama4-Dec-03 6:57
stateyama4-Dec-03 6:57 
GeneralTextBox Arrays Pin
spindar3-Dec-03 13:33
spindar3-Dec-03 13:33 
GeneralRe: TextBox Arrays Pin
Colin Angus Mackay3-Dec-03 15:03
Colin Angus Mackay3-Dec-03 15:03 
GeneralRe: TextBox Arrays Pin
Nick Seng3-Dec-03 15:40
Nick Seng3-Dec-03 15:40 
GeneralRe: TextBox Arrays Pin
Heath Stewart4-Dec-03 4:28
protectorHeath Stewart4-Dec-03 4:28 
GeneralWaiting for threads finish question Pin
clayne3-Dec-03 12:48
clayne3-Dec-03 12:48 
GeneralRe: Waiting for threads finish question Pin
Heath Stewart4-Dec-03 4:26
protectorHeath Stewart4-Dec-03 4:26 
GeneralRe: Waiting for threads finish question Pin
clayne4-Dec-03 8:37
clayne4-Dec-03 8:37 
QuestionHow to play audio files ? Pin
pahluwalia3-Dec-03 5:31
pahluwalia3-Dec-03 5:31 
AnswerRe: How to play audio files ? Pin
Heath Stewart3-Dec-03 6:29
protectorHeath Stewart3-Dec-03 6:29 
GeneralRichTextBox contents in a DB Pin
phimix3-Dec-03 5:19
phimix3-Dec-03 5:19 
GeneralRe: RichTextBox contents in a DB Pin
Heath Stewart3-Dec-03 6:27
protectorHeath Stewart3-Dec-03 6:27 
GeneralRe: RichTextBox contents in a DB Pin
Joel Lucsy3-Dec-03 8:43
Joel Lucsy3-Dec-03 8:43 
GeneralRe: Creating a new database... Pin
Heath Stewart3-Dec-03 5:15
protectorHeath Stewart3-Dec-03 5:15 
GeneralCreating a new database... Pin
Amirjalaly3-Dec-03 5:09
Amirjalaly3-Dec-03 5:09 
QuestionHow to display text the same way as printed? Pin
Loke13-Dec-03 3:59
Loke13-Dec-03 3:59 
GeneralCultureInfo Pin
Member 7439443-Dec-03 2:43
Member 7439443-Dec-03 2:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.