Esempio n. 1
0
        public void EnvironmentSetUp()
        {
            var confSection = DeployerConfigurationSection.Instance;

            _surveyName  = "Test" + TestUtils.GetPostfix();
            _surveyPath  = Path.Combine(confSection.Settings.Paths.Surveys, _surveyName);
            _credentials = new Credentials(
                confSection.Settings.Credentials.Domain,
                confSection.Settings.Credentials.Login,
                confSection.Settings.Credentials.Password);
            _iisInfo = new IISInfo(
                confSection.Settings.IIS.Version,
                confSection.Settings.IIS.Address,
                confSection.Settings.IIS.ApplicationPool,
                null
                );

            if (confSection.Settings.IIS.Version == "6")
            {
                Assert.Ignore("No configuration for IIS7");
            }

            if (!TryToImpersonate())
            {
                Assert.Ignore("Imersonation to '{0}\\{1}' failed", _credentials.Domain, _credentials.Login);
            }

            if (!TryConnectToIIS(confSection.Settings.IIS.Address))
            {
                Assert.Ignore("Connection to '" + _iisInfo.Address + "' IIS7 site failed");
            }
        }
Esempio n. 2
0
        private void toolStripOpenComputer_Click(object sender, EventArgs e)
        {
            OpenRemoteIISForm frm = new OpenRemoteIISForm();

            if (frm.ShowDialog() == DialogResult.OK)
            {
                if (frm.IISSelected != null)
                {
                    IISInfo iis     = frm.IISSelected;
                    string  key     = string.Format("$${0}", iis.IISInfoDisplay);
                    Guid    guidKey = Guid.NewGuid();
                    string  name    = iis.IISInfoDisplay;

                    if (!_listParser.ContainsKey(guidKey.ToString()))
                    {
                        CreateNewIISRemoteNode(guidKey.ToString(), name, 4);
                        // $$--> Remote IIS node key
                        AttachUserControl(guidKey.ToString(), name, 4);
                        tabMain.SelectedTab = tabMain.TabPages[guidKey.ToString()];
                        _computersNode.ExpandAll();

                        AttachIISRemoteLogParser(key, iis, guidKey);
                    }
                    else
                    {
                        tabMain.SelectedTab = tabMain.TabPages[guidKey.ToString()];
                    }
                }
            }
        }
Esempio n. 3
0
        private void btnConnect_Click(object sender, EventArgs e)
        {
            DirectoryEntry de = null;

            try
            {
                if (chkLocal.Checked)
                {
                    de = new DirectoryEntry("IIS://localhost/w3svc");
                }
                else
                {
                    de = new DirectoryEntry(string.Format("IIS://{0}/w3svc", txtComputerName.Text),
                                            txtUserId.Text,
                                            txtPassword.Text,
                                            AuthenticationTypes.Secure);
                }

                de.RefreshCache();

                _listIISInfo = new List <IISInfo>();
                foreach (DirectoryEntry child in de.Children)
                {
                    if (child.Properties["KeyType"].Value.ToString() == "IIsWebServer")
                    {
                        IISInfo obj = new IISInfo();
                        obj.Id            = child.Name;
                        obj.ServerComment = child.Properties["ServerComment"].Value.ToString();
                        obj.LogPath       = child.Properties["LogFileDirectory"].Value.ToString();

                        string   ports = child.Properties["ServerBindings"].Value.ToString();
                        string[] port  = ports.Split(new char[] { ':' });
                        if (port.Length > 1)
                        {
                            obj.ServerPort = port[1];
                        }

                        if (chkLocal.Checked)
                        {
                            obj.RemoteServer = "localhost";
                        }
                        else
                        {
                            obj.RemoteServer = txtComputerName.Text;
                        }

                        obj.LocalComputer = chkLocal.Checked;
                        obj.IISUserId     = txtUserId.Text;
                        obj.IISPassword   = txtPassword.Text;
                        _listIISInfo.Add(obj);
                    }
                }

                listWebsite.DataSource = _listIISInfo;
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message, "Error");
            }
        }
Esempio n. 4
0
        public LogParser(IISInfo info)
        {
            _startTime = 0;
            _endTime   = 0;
            QueryPerformanceFrequency(ref _freq);

            //_featureQueue = new ConcurrentQueue<FeatureDataRow>();
            _iisInfo    = info;
            LogParserId = Guid.NewGuid();
            _synContext = AsyncOperationManager.SynchronizationContext;
        }
Esempio n. 5
0
 private void btnSelect_Click(object sender, EventArgs e)
 {
     if (listWebsite.SelectedItem != null)
     {
         IISSelected  = (IISInfo)listWebsite.SelectedItem;
         DialogResult = DialogResult.OK;
         Close();
     }
     else
     {
         MessageBox.Show("Please select website you want to analyze", "Information");
     }
 }
Esempio n. 6
0
        private void AttachIISRemoteLogParser(string name, IISInfo info, Guid id)
        {
            LogParser parser = new LogParser(info)
            {
                FileName     = name,
                UseExistData = false,
                UseParallel  = true,
                LogParserId  = id
            };

            parser.AnalyzeLogHandler += OnAnalyzeLog;
            parser.EndAnalyzeHandler += OnEndAnalyze;

            parser.Analyze();
            _listParser.Add(id.ToString(), parser);
        }
        private static void ConfigureDestinationPath(IISInfo iisInfo)
        {
            string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            if (!Directory.Exists(String.Format("{0}\\Temp\\", path)))
            {
                Directory.CreateDirectory(String.Format("{0}\\Temp\\", path));
            }

            if (!Directory.Exists(String.Format("{0}\\Temp\\{1}{2}\\", path, iisInfo.RemoteServer, iisInfo.Id)))
            {
                Directory.CreateDirectory(String.Format("{0}\\Temp\\{1}{2}\\", path, iisInfo.RemoteServer, iisInfo.Id));
            }
            else
            {
                string[] filePaths = Directory.GetFiles(String.Format("{0}\\Temp\\{1}{2}\\", path, iisInfo.RemoteServer, iisInfo.Id));
                Array.ForEach(filePaths, File.Delete);
            }
        }
Esempio n. 8
0
        private static void ConfigureDestinationPath(IISInfo iisInfo)
        {
            string path = string.Format("{0}\\Indihiang\\", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData));

            if (!Directory.Exists(String.Format("{0}\\Temp\\", path)))
            {
                Directory.CreateDirectory(String.Format("{0}\\Temp\\", path));
            }

            if (!Directory.Exists(String.Format("{0}\\Temp\\{1}{2}\\", path, iisInfo.RemoteServer, iisInfo.Id)))
            {
                Directory.CreateDirectory(String.Format("{0}\\Temp\\{1}{2}\\", path, iisInfo.RemoteServer, iisInfo.Id));
            }
            else
            {
                string[] filePaths = Directory.GetFiles(String.Format("{0}\\Temp\\{1}{2}\\", path, iisInfo.RemoteServer, iisInfo.Id));
                Array.ForEach(filePaths, File.Delete);
            }
        }
Esempio n. 9
0
        private void InitializeSettings(DeployerConfigurationSection confSection)
        {
            Credentials = new Credentials(
                confSection.Settings.Credentials.Domain,
                confSection.Settings.Credentials.Login,
                confSection.Settings.Credentials.Password);
            Survey = new Survey(_context.UriName, _context.DatabaseName ?? _context.UriName, _context.Mode);
            var surveyDir = Path.Combine(confSection.Settings.Paths.Surveys, _context.DirectoryName ?? _context.UriName);

            SurveyPath   = new SurveyPaths(surveyDir, () => Path.Combine(surveyDir, "bin"));
            PackagePaths = new PackagePaths(
                Path.Combine(confSection.Settings.Paths.Uploads, _context.UriName + ".zip"),
                Path.Combine(confSection.Settings.Paths.Backups, _context.UriName + ".zip"));
            CommonPaths = new CommonPaths(
                confSection.Settings.Paths.Surveys,
                confSection.Settings.Paths.Uploads,
                confSection.Settings.Paths.Backups);
            DbScriptsPaths = new DbScriptsPaths(
                confSection.Settings.ScriptsPaths.DbCreate,
                confSection.Settings.ScriptsPaths.DbValidate,
                confSection.Settings.ScriptsPaths.DbDelete);
            Templates = new TemplatesPaths(
                confSection.Settings.Templates.ConnectionStrings,
                confSection.Settings.Paths.AdditionalResources.Bins);
            ConnectionStrings = new ConnectionStrings(
                ConfigurationManager.ConnectionStrings["master"].ConnectionString,
                ConfigurationManager.ConnectionStrings["deployer"].ConnectionString);
            IIS = new IISInfo(
                confSection.Settings.IIS.Version,
                confSection.Settings.IIS.Address,
                confSection.Settings.IIS.ApplicationPool,
                confSection.Settings.IIS.DirsWithIISAccess == null
                    ? new List <KeyValuePair <string, string> >()
                    : confSection.Settings.IIS.DirsWithIISAccess.Cast <DirElement>()
                .Select(dir => new KeyValuePair <string, string>(dir.Name, dir.User)));
        }
Esempio n. 10
0
 public IIISManager CreateIISManager(IISInfo iis, string surveyUri)
 {
     return(_iismFactory(iis, surveyUri));
 }
Esempio n. 11
0
 public IIS6Manager(IISInfo iisInfo, string surveyName)
 {
     _iisInfo    = iisInfo;
     _surveyName = surveyName;
 }
Esempio n. 12
0
        public static bool CopyRemoteFiles(IISInfo iisInfo)
        {
            bool            success     = false;
            IntPtr          admin_token = default(IntPtr);
            WindowsIdentity wid_current = WindowsIdentity.GetCurrent();
            WindowsIdentity wid_admin   = null;

            admin_token = wid_current.Token;
            WindowsImpersonationContext wic = null;

            try
            {
                string uid    = "";
                string domain = "";
                string tmp    = iisInfo.IISUserId;
                if (tmp.Contains("\\"))
                {
                    string[] temp1 = tmp.Split(new char[] { '\\' });
                    if (temp1 != null)
                    {
                        uid    = temp1[0];
                        domain = temp1[1];
                    }
                }
                else
                {
                    uid    = iisInfo.IISUserId;
                    domain = iisInfo.RemoteServer;
                }

                if (LogonUser(uid, domain, iisInfo.IISPassword, 9, 0, ref admin_token) != 0)
                {
                    ConfigureDestinationPath(iisInfo);

                    string pathSource = "";
                    if (!iisInfo.LocalComputer)
                    {
                        pathSource = iisInfo.LogPath.Replace(":", "$");
                    }

                    string dir      = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                    string pathDest = String.Format("{0}\\Temp\\{1}{2}\\", dir, iisInfo.RemoteServer, iisInfo.Id);

                    wid_admin = new WindowsIdentity(admin_token);
                    wic       = wid_admin.Impersonate();

                    string[] files = null;
                    files = Directory.GetFiles(String.Format("\\\\{0}\\{1}\\W3SVC{2}\\", iisInfo.RemoteServer, pathSource, iisInfo.Id));

                    //if (iisInfo.LocalComputer)
                    //{
                    //    files = Directory.GetFiles(String.Format("{0}\\W3SVC{1}\\", iisInfo.LogPath, iisInfo.Id));
                    //}
                    //else
                    //    files = Directory.GetFiles(String.Format("\\\\{0}\\{1}\\W3SVC{2}\\", iisInfo.RemoteServer, pathSource,iisInfo.Id));

                    if (files != null)
                    {
                        Array.ForEach(files, s =>
                        {
                            string fileName = Path.GetFileName(s);
                            string destFile = Path.Combine(pathDest, fileName);
                            File.Copy(s, destFile, true);
                        });
                    }
                    success = true;
                }
            }
            catch (Exception err)
            {
                System.Diagnostics.Debug.WriteLine(String.Format("Error CopyRemoteFiles: {0}", err.Message));
                System.Diagnostics.Debug.WriteLine(String.Format("Error CopyRemoteFiles: {0}", err.StackTrace));
            }

            return(success);
        }