Suppress login dialog when impersonation on?

Discussion in 'ASP .Net Security' started by Gary H., Jul 14, 2003.

  1. Gary H.

    Gary H. Guest

    Does anyone know how I can suppress the "Enter Network
    Password" dialog when attempting to enumerate directories
    and/or files in ASP.NET? I want my code to automatically
    generate an exception if the current user is not allowed
    to access a share folder or file instead of prompting the
    user to enter a username/pwd. I'm using:

    dirs = Directory.GetDirectories(sPath)

    Or, is there an easier way to determine if the current
    user has access to a share folder/file?

    Thanks, Gary.
    Gary H., Jul 14, 2003
    #1
    1. Advertising

  2. Hi Gary ,

    You can use the try-catch block to catch the permission denied exceptions.
    When you attempt to access files/folders that you are granted access to,
    you will get SecurityException exceptions. You can catch the exceptions and
    return a message to the user that he/her has no permission to the resource.

    For example:

    private void Button1_Click(object sender, System.EventArgs e)
    {
    try
    {
    string[] dirs=Directory.GetDirectories("H:\\WUTemp");
    foreach(string dir in dirs)
    DropDownList1.Items.Add(dir);
    }
    catch(Exception e1)
    {
    //Return a message to users
    Label1.Text =e1.Message;
    }
    }

    Regards,

    Felix Wu
    =======
    This posting is provided "AS IS" with no warranties, and confers no rights.

    --------------------
    >Content-Class: urn:content-classes:message
    >From: "Gary H." <>
    >Sender: "Gary H." <>
    >Subject: Suppress login dialog when impersonation on?
    >Date: Mon, 14 Jul 2003 09:17:15 -0700
    >Lines: 14
    >Message-ID: <01af01c34a23$63b89da0$>
    >MIME-Version: 1.0
    >Content-Type: text/plain;
    > charset="iso-8859-1"
    >Content-Transfer-Encoding: 7bit
    >X-Newsreader: Microsoft CDO for Windows 2000
    >X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
    >Thread-Index: AcNKI2O4spXv0Q1QT+6akK2rFOW1zQ==
    >Newsgroups: microsoft.public.dotnet.framework.aspnet.security
    >Path: cpmsftngxa06.phx.gbl
    >Xref: cpmsftngxa06.phx.gbl

    microsoft.public.dotnet.framework.aspnet.security:5882
    >NNTP-Posting-Host: TK2MSFTNGXA09 10.40.1.161
    >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.security
    >
    >Does anyone know how I can suppress the "Enter Network
    >Password" dialog when attempting to enumerate directories
    >and/or files in ASP.NET? I want my code to automatically
    >generate an exception if the current user is not allowed
    >to access a share folder or file instead of prompting the
    >user to enter a username/pwd. I'm using:
    >
    >dirs = Directory.GetDirectories(sPath)
    >
    >Or, is there an easier way to determine if the current
    >user has access to a share folder/file?
    >
    >Thanks, Gary.
    >
    >
    Felix Wu [MSFT], Jul 17, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Not Me
    Replies:
    6
    Views:
    967
    Norman Yuan
    Dec 20, 2006
  2. yw
    Replies:
    3
    Views:
    807
    Phlip
    Jul 2, 2005
  3. Roan Schuurman

    Fixed Impersonation vs Current login user

    Roan Schuurman, May 11, 2004, in forum: ASP .Net Security
    Replies:
    2
    Views:
    143
    Roan Schuurman
    May 25, 2004
  4. Matt
    Replies:
    1
    Views:
    269
    Randy Webb
    Nov 20, 2004
  5. Replies:
    2
    Views:
    292
    Bart Van der Donck
    May 12, 2006
Loading...

Share This Page