Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using GetFiles function with the following.

Status
Not open for further replies.

cjinsocal581

Programmer
Feb 5, 2005
168
US
Here is code that I am trying to get working.
____________________________________________________
Code:
Option Explicit On

Imports Microsoft.VisualBasic
Imports System
Imports System.IO
Imports System.Security
Imports System.Security.Permissions
Imports System.Security.Principal
Imports System.Threading

Public Class Form1

    Inherits System.Windows.Forms.Form

Private strPath As String = "\\10.1.1.106\cjdev$"

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim rolesArray As String() = {"managers", "executives"}
        Try
            'Set the principal to a new generic principal.
            Thread.CurrentPrincipal = _
                New GenericPrincipal(New GenericIdentity( _
                "administrator", "password"), rolesArray)

        Catch secureException As SecurityException
            Debug.WriteLine("{0}: Permission to set Principal " & _
               "is denied.", secureException.GetType().Name)
        End Try

        Dim threadPrincipal As IPrincipal = Thread.CurrentPrincipal
        Console.WriteLine( _
            "Name: {0}" & vbCrLf & "IsAuthenticated:" & _
            " {1}" & vbCrLf & "AuthenticationType: {2}", _
            threadPrincipal.Identity.Name, _
            threadPrincipal.Identity.IsAuthenticated, _
            threadPrincipal.Identity.AuthenticationType)

        Debug.WriteLine(System.Threading.Thread.CurrentPrincipal)
        Dim strFile As String, SelectedItem As ListViewItem
        Dim thisFile As FileInfo
        Dim thisDir As New DirectoryInfo(strPath)

        For Each thisFile In thisDir.GetFiles("*.wav")
            SelectedItem = ListView1.Items.Add(thisFile.Name, 0)
            SelectedItem.SubItems.Add(Now())
        Next

    End Sub
_________________________________________________________

So, with the code on the above mentioned question, I need to make the following work.

I need to connect to a HIDDEN share and impersonating authentication on a server. List the files withing that share and have access to them.

PLEASE do not suggest unhiding the share. This IS NOT an option due to basic security requirements, I need to somehow get this solution to work.

Better yet, if you can get it to "prompt" for user name and password, that would be awesome.

Any ideas?
 
Would love to know if/when you get anywhere with this. I can see myself facing exactly this scenarion in the non topo distant future.


Sweep
...if it works dont mess with it
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top