access to network shared
-
Hi I'm trying to do a directory listing on a network shared (\\machinename\sharedfolder) which granted everyone read/list access. I have my authentication mode set to Window and identity impersonate = false (our standard) in the web.config file. I tried to use the below code. However, I'm getting "Login Failure: unknown user name or bad password". If I just add a hyperlink to a file under that share, it opens the file with no problem. Dim impersonationContext As WindowsImpersonationContext Dim currentWindowsIdentity As WindowsIdentity = CType(User.Identity, WindowsIdentity) impersonationContext = currentWindowsIdentity.Impersonate() Dim ds As New DataSet Dim dt As New DataTable("Files") Dim dr As DataRow dt.Columns.Add("Filename", GetType(String)) Dim objDirInfo As New DirectoryInfo("\\machinename\sharedfolder\") Dim fi As FileInfo Dim fileInfos() As FileInfo fileInfos = objDirInfo.GetFiles("*.*") Dim i As Integer = fileInfos.Length If i > 0 Then For Each fi In fileInfos dr = dt.NewRow() dr(0) = fi.Name dt.Rows.Add(dr) Next End If ds.Tables.Add(dt) Me.DataGrid1.DataSource = ds Me.DataGrid1.DataBind() impersonationContext.Undo() Can anyone help? thank you
-
Hi I'm trying to do a directory listing on a network shared (\\machinename\sharedfolder) which granted everyone read/list access. I have my authentication mode set to Window and identity impersonate = false (our standard) in the web.config file. I tried to use the below code. However, I'm getting "Login Failure: unknown user name or bad password". If I just add a hyperlink to a file under that share, it opens the file with no problem. Dim impersonationContext As WindowsImpersonationContext Dim currentWindowsIdentity As WindowsIdentity = CType(User.Identity, WindowsIdentity) impersonationContext = currentWindowsIdentity.Impersonate() Dim ds As New DataSet Dim dt As New DataTable("Files") Dim dr As DataRow dt.Columns.Add("Filename", GetType(String)) Dim objDirInfo As New DirectoryInfo("\\machinename\sharedfolder\") Dim fi As FileInfo Dim fileInfos() As FileInfo fileInfos = objDirInfo.GetFiles("*.*") Dim i As Integer = fileInfos.Length If i > 0 Then For Each fi In fileInfos dr = dt.NewRow() dr(0) = fi.Name dt.Rows.Add(dr) Next End If ds.Tables.Add(dt) Me.DataGrid1.DataSource = ds Me.DataGrid1.DataBind() impersonationContext.Undo() Can anyone help? thank you
-
I doubt your security token being return is valid 1 line of code equals many bugs. So don't write any!!
-
thanks for your reply. However, I'm not quite sure what you mean. I'm new at asp.net. How do I do file listing on a network shared then? thank you
-
this is a good example of impersonation http://www.codeproject.com/csharp/cpimpersonation1.asp[^] 1 line of code equals many bugs. So don't write any!!
-
this is a good example of impersonation http://www.codeproject.com/csharp/cpimpersonation1.asp[^] 1 line of code equals many bugs. So don't write any!!
-
Although I get "access to path is denied" message, I can create a link to open a file under that share directly. ( Any ideas?
-
check the user that is set to "run as" inside the IIS console 1 line of code equals many bugs. So don't write any!!
-
Hi Are you referring to the Authentication Methods? I checked Integrated Windows authentication" only. thank you for being so repsonsive.
no. In my last posts I staed you should check your user under IIS. So go to start->control panel->Admin->IIS right click properties on your web site and check that user. Odds are he doesn't have permissions to access that folder 1 line of code equals many bugs. So don't write any!!
-
no. In my last posts I staed you should check your user under IIS. So go to start->control panel->Admin->IIS right click properties on your web site and check that user. Odds are he doesn't have permissions to access that folder 1 line of code equals many bugs. So don't write any!!
-
when I right click properties on my IIS website, I get the Properties pop up and I see the -Virtual Directory tab -Documents tab -Directory Security tab -HTTP Headers tab -Custom Errors tab Where do I check the User? thanks
DirectorySecurity -> click "Edit" button That will tell you the user your looking for. then armed with that information, right click on the network share and give that user permission to do what should be done. I don't memorize the tabs. So I usually just click on them until I find the right one. You will start using this constantly. 1 line of code equals many bugs. So don't write any!!
-
DirectorySecurity -> click "Edit" button That will tell you the user your looking for. then armed with that information, right click on the network share and give that user permission to do what should be done. I don't memorize the tabs. So I usually just click on them until I find the right one. You will start using this constantly. 1 line of code equals many bugs. So don't write any!!