예제 #1
0
        private bool establish_connection(NETRESOURCE target_resource)
        {
            //ask creds
            string user_name = string.Empty;
            string ps        = string.Empty;

            if (Messages.AskCredentials
                    ("Network login",
                    "Connect to " + target_resource.lpRemoteName,
                    ref user_name,
                    ref ps) != System.Windows.Forms.DialogResult.OK)
            {
                return(false);
            }

            int res = WinApiWNET.WNetAddConnection2
                          (ref target_resource,
                          ps,
                          user_name,
                          WNetConnectOptions.None);

            if (res != WinApiWNET.NO_ERROR)
            {
                Win32Exception win_ex = new Win32Exception(res);
                Messages.ShowException(win_ex);
                return(false);
            }
            return(true);
        }
예제 #2
0
        private bool establish_connection(NETRESOURCE target_resource)
        {
            //ask creds
            var user_name = string.Empty;
            var ps        = string.Empty;

            if (Messages.AskCredentials
                    (Options.GetLiteral(Options.LANG_NETWORK_LOGIN),
                    "Connect to " + target_resource.lpRemoteName,
                    ref user_name,
                    ref ps) != System.Windows.Forms.DialogResult.OK)
            {
                return(false);
            }

            var res = WinApiWNET.WNetAddConnection2
                          (ref target_resource,
                          ps,
                          user_name,
                          WNetConnectOptions.None);

            if (res != WinApiWNET.NO_ERROR)
            {
                var win_ex = new Win32Exception(res);
                Messages.ShowException(win_ex);
                return(false);
            }
            return(true);
        }