CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 1999
    Posts
    23

    connecting to user/password protected server

    Hi, i have written an app that needs to connect to a server that has access rights associated with it. If i am logged on as a certain person who has access privaleges there is not a problem. In certain circumstances the computer running my app has not network connection to a domain. I have programmed access to the domain but the server i need to access data on in the domain is user and password protected. If i use the following code i cannot access the file.

    using (StreamReader sr = new StreamReader("\\\\Ukptserver03\\Archive\\Users.Dat"))
    {
    String line;
    while ((line = sr.ReadLine()) != null)
    {
    .....etc

    Are there any other parameters i need to pass to the streamreader or do i need to set something else up.

    Thanks.

  2. #2
    Join Date
    Mar 2008
    Posts
    72

    Re: connecting to user/password protected server

    Here's an article showing you how to impersonate a specific user in code.

    http://support.microsoft.com/?id=306158#4

    If you throw an exception, whatever code catches it will also run in that security context, so watch out for that.

  3. #3
    Join Date
    Jun 1999
    Posts
    23

    Re: connecting to user/password protected server

    Quote Originally Posted by MikeVallotton
    Here's an article showing you how to impersonate a specific user in code.

    http://support.microsoft.com/?id=306158#4

    If you throw an exception, whatever code catches it will also run in that security context, so watch out for that.
    Thanks for this, it is very helpful.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured