Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2011
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.13 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9.  
  10. using System.Diagnostics;
  11.  
  12. using Iuf.Network.Authentication;
  13.  
  14. namespace AccessPool
  15. {
  16.     public partial class Form1 : Form
  17.     {
  18.         Impersonation UserAccess;
  19.         Process FileProcess;
  20.  
  21.         public Form1()
  22.         {
  23.             InitializeComponent();
  24.         }
  25.  
  26.         private void Form1_Load(object sender, EventArgs e)
  27.         {
  28.         }
  29.  
  30.         private void btnButton_Click(object sender, EventArgs e)
  31.         {
  32.             UserAccess = new Impersonation(txtUsername.Text, txtPassword.Text, "ametikool.local");
  33.  
  34.             try
  35.             {
  36.                 UserAccess.ImpersonateUser();
  37.             }
  38.             catch (Exception ImpersonateException)
  39.             {
  40.                 MessageBox.Show(ImpersonateException.ToString());
  41.             }
  42.             finally
  43.             {
  44.                 MessageBox.Show("Access granted!");
  45.                 btnOpenFile.Enabled = true;
  46.             }
  47.         }
  48.  
  49.         private void btnOpenFile_Click(object sender, EventArgs e)
  50.         {
  51.             OpenFileDialog FileDialogObject = null;
  52.  
  53.             try
  54.             {
  55.                 FileDialogObject = new OpenFileDialog();
  56.                 FileDialogObject.ShowDialog();
  57.             }
  58.             catch (Exception FileDialogException)
  59.             {
  60.                 MessageBox.Show(FileDialogException.ToString());
  61.                 return;
  62.             }
  63.             finally
  64.             {
  65.                 txtFilePath.Text = FileDialogObject.FileName;
  66.             }
  67.         }
  68.  
  69.         private void btnRun_Click(object sender, EventArgs e)
  70.         {
  71.             try
  72.             {
  73.                 FileProcess = new Process();
  74.                 FileProcess.StartInfo.FileName = txtFilePath.Text;
  75.                 FileProcess.Start();
  76.             }
  77.             catch (Exception FileProcessException)
  78.             {
  79.                 MessageBox.Show(FileProcessException.ToString());
  80.             }
  81.         }
  82.     }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement