访问路径被拒绝 [英] access path is denied

查看:87
本文介绍了访问路径被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据提供的代码要访问C $,您必须是目标计算机上的管理员".
但是没有本地节点m/c的用户名和密码,并且与服务器m/c相同.
我该如何解决我发布的问题??
请提供信息..
我在等待正确的方式……

下面的代码
--------------------------------------

To according providing your''s code ''To access the C$ you have to be an administrator on the target machine''.
But have no user name and password of local node m/c and same as server m/c.
how can i solve my posted problem????
please provide information..
I wait for right way......

Code below
--------------------------------------

Imports System
Imports System.Runtime.InteropServices
Imports System.Security.Principal
Imports System.Security.Permissions
Public Class Form1
    <dllimport("advapi32.dll",> _
    Public Shared Function LogonUser(ByVal lpszUsername As String, ByVal lpszDomain As String, _
        ByVal lpszPassword As String, ByVal dwLogonType As Integer, ByVal dwLogonProvider As Integer, _
        ByRef phToken As IntPtr) As Integer
    End Function
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim admin_token As IntPtr
        Dim wid_current As WindowsIdentity = WindowsIdentity.GetCurrent()
        Dim wid_admin As WindowsIdentity = Nothing
        Dim wic As WindowsImpersonationContext = Nothing
        Try
            MessageBox.Show("Copying file...")
            ' ''If LogonUser("Local Admin name", "Local computer name", "pwd", 9, 0, admin_token) <> 0 Then
            If LogonUser("SNEHASIS\Administrator", "SNEHASIS", "", 9, 0, admin_token) <> 0 Then
                wid_admin = New WindowsIdentity(admin_token)
                wic = wid_admin.Impersonate()
                System.IO.File.Copy("C:\file.txt", "\\192.168.1.10\g$\ss\Test", True) ''157.60.113.28
                MessageBox.Show("Copy succeeded")
            Else
                MessageBox.Show("Copy Failed")
            End If
        Catch se As System.Exception
            Dim ret As Integer = Marshal.GetLastWin32Error()
            MessageBox.Show(ret.ToString(), "Error code: " + ret.ToString())
            MessageBox.Show(se.Message)
        Finally
            If wic IsNot Nothing Then
                wic.Undo()
            End If
        End Try
    End Sub
End Class

推荐答案

您必须是目标计算机上的管理员''.
但是没有本地节点m/c的用户名和密码,并且与服务器m/c相同.
我该如何解决我发布的问题??
请提供信息..
我在等待正确的方式……

下面的代码
--------------------------------------

you have to be an administrator on the target machine''.
But have no user name and password of local node m/c and same as server m/c.
how can i solve my posted problem????
please provide information..
I wait for right way......

Code below
--------------------------------------

Imports System
Imports System.Runtime.InteropServices
Imports System.Security.Principal
Imports System.Security.Permissions
Public Class Form1
    <dllimport("advapi32.dll",> _
    Public Shared Function LogonUser(ByVal lpszUsername As String, ByVal lpszDomain As String, _
        ByVal lpszPassword As String, ByVal dwLogonType As Integer, ByVal dwLogonProvider As Integer, _
        ByRef phToken As IntPtr) As Integer
    End Function
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim admin_token As IntPtr
        Dim wid_current As WindowsIdentity = WindowsIdentity.GetCurrent()
        Dim wid_admin As WindowsIdentity = Nothing
        Dim wic As WindowsImpersonationContext = Nothing
        Try
            MessageBox.Show("Copying file...")
            ' ''If LogonUser("Local Admin name", "Local computer name", "pwd", 9, 0, admin_token) <> 0 Then
            If LogonUser("SNEHASIS\Administrator", "SNEHASIS", "", 9, 0, admin_token) <> 0 Then
                wid_admin = New WindowsIdentity(admin_token)
                wic = wid_admin.Impersonate()
                System.IO.File.Copy("C:\file.txt", "\\192.168.1.10\g


\ ss \ Test",)' '157.60.113.28 MessageBox.Show(" ) 其他 MessageBox.Show(" ) 结束 如果 捕获 se As System.Exception Dim ret As 整数 = Marshal.GetLastWin32Error () MessageBox.Show(ret.ToString()," + ret.ToString()) MessageBox.Show(se.Message) 最后 如果 wic 是不是 没什么 然后 wic.Undo() 结束 如果 结束 尝试 结束 结束
\ss\Test", True) ''157.60.113.28 MessageBox.Show("Copy succeeded") Else MessageBox.Show("Copy Failed") End If Catch se As System.Exception Dim ret As Integer = Marshal.GetLastWin32Error() MessageBox.Show(ret.ToString(), "Error code: " + ret.ToString()) MessageBox.Show(se.Message) Finally If wic IsNot Nothing Then wic.Undo() End If End Try End Sub End Class


我认为你的意思是作为对其他问题/答案的答复.
如果是这样,则使用该问题的答复"功能,或者组合使用改善问题"然后答复",以使该人知道.仅仅发布为新问题根本没有帮助-回答者可能永远看不到它.
I think you meant this as a reply to some other question / answer.
If so, then use the "reply" feature of that question, or a combination of "Improve question" and then "reply" to let the person know. Just posting as a new question is not at all helpful - the answerer may never see it.


这篇关于访问路径被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆