如何打开与另一个域(VB.NET)的连接 [英] How to open a connection to another domain (VB.NET)

查看:48
本文介绍了如何打开与另一个域(VB.NET)的连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Private Sub Open_Remote_Connection(ByVal strComputer As String, ByVal strUsername As String, ByVal strPassword As String)
        
        Dim ProcessStartInfo As New System.Diagnostics.ProcessStartInfo
        ProcessStartInfo.FileName = "net"
        ProcessStartInfo.Arguments = "use \\" & strComputer & " /USER:" & strUsername & " " & strPassword
        ProcessStartInfo.WindowStyle = ProcessWindowStyle.Hidden
        System.Diagnostics.Process.Start(ProcessStartInfo)

        System.Threading.Thread.Sleep(2000)
    End Sub



我在复制方法之前使用此方法,以允许服务器在复制之前对我进行身份验证.我在相同的域"A"中制作了服务器的文件副本,并且成功.但是,当我将域"A"中的服务器的文件复制到域"B"中的服务器时,出现访问被拒绝的异常.我使用的凭据是两台服务器的管理员帐户.

谢谢!任何帮助都是好的!



I use this method before a copy method to allow the server to authenticate me before copy. I did a file copy of servers within the same domain ''A'' and it succeeded. However when I did a file copy of a server in domain ''A'' to a server in domain ''B'' it came out access denied exception. The credentials I used were Admin accounts of both servers.

Thanks! Any help would be good!

推荐答案

嗯,那行不通.当您在同一个域中执行此操作时,它看起来可能像它一样起作用,但实际上却没有.一旦返回NET命令,该进程及其环境,我们便将其销毁.

使用 WNetAddConnect2 [此处 [
Well, that''s not going to work. It may LOOK like it works when you did it in the same domain but you really didn''t. As soon as the NET command returned, that process, and its environment, we destroyed.

Use WNetAddConnect2[^] instead.

You can see an example of how to do it here[^].


这篇关于如何打开与另一个域(VB.NET)的连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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