コード例 #1
0
        /// <summary>
        /// Reads the target machine info for the current plugin from credentilas ini and assign to Hostinfo
        /// </summary>
        /// <param name="requestor"></param>
        /// <param name="_hn"></param>
        public static void GetConnectedHostInfoFromIni(IPlugIn requestor, Hostinfo _hn)
        {
            string sPlugInName = requestor.GetName();

            bool IsFileExists = !string.IsNullOrEmpty(sCredentialsFilePath) && Path.IsPathRooted(sCredentialsFilePath) && File.Exists(sCredentialsFilePath);

            if (!IsFileExists)
            {
                return;
            }

            StreamReader reader = new StreamReader(sCredentialsFilePath);

            while (!reader.EndOfStream)
            {
                string currentLine = reader.ReadLine();
                if (currentLine != null && currentLine.Trim().Equals(sPlugInName))
                {
                    currentLine = reader.ReadLine();

                    int index = 0;
                    if (currentLine != null && currentLine.Trim().IndexOf("hostname=") >= 0 &&
                        String.IsNullOrEmpty(_hn.hostName))
                    {
                        currentLine  = currentLine.Trim();
                        index        = (currentLine.IndexOf('=') + 1);
                        _hn.hostName = currentLine.Substring(index, (currentLine.Length - index));
                        currentLine  = reader.ReadLine();
                    }

                    if (currentLine != null && currentLine.Trim().IndexOf("username="******"domainFQDN=") >= 0 &&
                        String.IsNullOrEmpty(_hn.domainName))
                    {
                        currentLine    = currentLine.Trim();
                        index          = (currentLine.IndexOf('=') + 1);
                        _hn.domainName = currentLine.Substring(index, (currentLine.Length - index));
                        currentLine    = reader.ReadLine();
                    }

                    if (currentLine != null && currentLine.IndexOf("domainShort=") >= 0 &&
                        String.IsNullOrEmpty(_hn.creds.Domain))
                    {
                        currentLine      = currentLine.Trim();
                        index            = (currentLine.IndexOf('=') + 1);
                        _hn.creds.Domain = currentLine.Substring(index, (currentLine.Length - index));
                    }
                    break;
                }
            }
            reader.Close();
        }
コード例 #2
0
 public ObjectSelectDlg(IPlugInContainer container, StandardPage parentPage, Hostinfo hn, IPlugIn plugin)
     : this()
 {
     this.IPlugInContainer = container;
     //this.AddPage(new DomainConnectPage(this, hn, plugin, container));
     this.AddPage(new ObjectSelectPage(this, plugin, container));
 }
コード例 #3
0
        /// <summary>
        /// If Host information is not null then refreshes the ADUC plugin for each domain on mouse left click
        /// Else reinitializes the ADUC plugin node
        /// </summary>
        /// <param name="hn"></param>
        public void SetContext(IContext ctx)
        {
            Hostinfo hn = ctx as Hostinfo;

            Logger.Log(String.Format("ADUCPlugin.SetHost(hn: {0})",
                                     hn == null ? "null" : hn.ToString()), Logger.manageLogLevel);

            _hn = hn;

            if (_hn != null &&
                !String.IsNullOrEmpty(_hn.domainName) &&
                !(_usingSimpleBind && !Hostinfo.HasCreds(_hn)))
            {
                Logger.Log("ADUCPlugin.SetHost: connecting to domain");

                ConnectToDomain();

                if (!_usingSimpleBind && !_hn.IsConnectionSuccess)
                {
                    _usingSimpleBind = true;
                }

                //sethost on all the extension plugins
                if (_extPlugins != null)
                {
                    foreach (IPlugIn extPlugin in _extPlugins)
                    {
                        extPlugin.SetContext(_hn);
                    }
                }
            }
        }
コード例 #4
0
        public void CreateDlg()
        {
            Logger.Log("LUGPage.CreateDlg() called", Logger.netAPILogLevel);

            try
            {
                if (memberType == LUGAPI.LUGType.User)
                {
                    NewUserDlg nuDlg = new NewUserDlg(this.container, this);
                    nuDlg.ShowDialog(this);
                    Refresh();
                }
                else if (memberType == LUGAPI.LUGType.Group)
                {
                    Hostinfo    hn    = ctx as Hostinfo;
                    NewGroupDlg ngDlg = new NewGroupDlg(this.container, this, hn, base.pi);
                    ngDlg.ShowDialog(this);
                    Refresh();
                }
            }
            catch (Exception except)
            {
                container.ShowError(except.Message);
            }
        }
コード例 #5
0
        public override void Refresh()
        {
            base.Refresh();
            Hostinfo hn = ctx as Hostinfo;

            if (nodeType == FileShareManagerIPlugIn.PluginNodeType.SHARES)
            {
                Dictionary <int, string[]> ShareList = null;

                if (lvSharePage.Items.Count != 0)
                {
                    lvSharePage.Items.Clear();
                }

                if (Configurations.currentPlatform != LikewiseTargetPlatform.Windows)
                {
                    if (plugin.fileHandle != null && plugin.fileHandle.Handle != null)
                    {
                        ShareList = SharesAPI.EnumShares(plugin.fileHandle.Handle, hn.creds, hn.hostName);
                    }
                    else
                    {
                        Logger.Log("SharesPage.Refresh: SharesAPI.Handle returned null", Logger.LogLevel.Error);
                        return;
                    }
                }
                else
                {
                    ShareList = SharesAPI.EnumShares(IntPtr.Zero, hn.creds, hn.hostName);
                }

                if (ShareList == null)
                {
                    Logger.Log("SharesPage.Refresh: SharesAPI.EnumShares returned null", Logger.LogLevel.Error);
                    return;
                }

                foreach (int i in ShareList.Keys)
                {
                    ListViewItem lvItem = new ListViewItem(ShareList[i]);
                    lvSharePage.Items.Add(lvItem);
                }
            }
            else
            {
                ListViewItem[] itemlist = new ListViewItem[treeNode.Nodes.Count];
                int            index    = 0;

                foreach (LACTreeNode node in treeNode.Nodes)
                {
                    ListViewItem item = new ListViewItem(new string[] { node.Text });
                    itemlist[index] = item;
                    index++;
                }
                if (itemlist.Length != 0)
                {
                    lvSharePage.Items.AddRange(itemlist);
                }
            }
        }
コード例 #6
0
ファイル: FilesPage.cs プロジェクト: vmware/likewise-open
        private void acClose_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (lvFilePage.SelectedItems.Count != 1)
            {
                return;
            }

            // get the accessing machine and user name of the session to close
            ListViewItem Item    = lvFilePage.SelectedItems[0];
            string       sFileId = (string)Item.SubItems[4].Text;

            try
            {
                int      nFileId = int.Parse(sFileId);
                Hostinfo hn      = ctx as Hostinfo;

                if (plugin.fileHandle != null)
                {
                    SharesAPI.CloseFile(IntPtr.Zero, hn.creds, hn.hostName, nFileId);
                }
                else
                {
                    SharesAPI.CloseFile(plugin.fileHandle.Handle, hn.creds, hn.hostName, nFileId);
                }

                Refresh();
            }
            catch (Exception ex)
            {
                string sMsg = string.Format(Resources.Error_UnableToCloseFile, ex.Message);
                container.ShowError(sMsg);
            }
        }
コード例 #7
0
        private void acViewShare_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            ListViewItem Item = GetSelectedItem();

            if (Item == null)
            {
                return;
            }
            string   sShare = (string)Item.SubItems[0].Text;
            Hostinfo hn     = ctx as Hostinfo;

            if (Configurations.currentPlatform == LikewiseTargetPlatform.Windows)
            {
                SharesAPI.ViewShare(hn.creds, hn.hostName, sShare);
            }
            else
            {
                if (File.Exists(sShare))
                {
                    ProcessStartInfo startInfo = new ProcessStartInfo("nautilus", sShare);
                    startInfo.RedirectStandardOutput = true;
                    startInfo.UseShellExecute        = false;
                    startInfo.Verb        = "open";
                    startInfo.WindowStyle = ProcessWindowStyle.Normal;
                    Process.Start(startInfo);
                    return;
                }
            }
        }
コード例 #8
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            string errorMessage = null;

            if (Hostinfo.ValidatePassword(_sNewPassword, _sConfirmPassword, out errorMessage))
            {
                uint result = (uint)LUGAPI.WinError.ERROR_SUCCESS;

                try
                {
                    result = LUGAPI.NetChangePassword(
                        _sHostName, _sUserName, _sNewPassword);
                }
                catch (Exception)
                {
                    result = (uint)LUGAPI.WinError.ERROR_EXCEPTION_IN_SERVICE;
                }

                if (result == (uint)LUGAPI.WinError.ERROR_SUCCESS)
                {
                    this.DialogResult = DialogResult.OK;
                    Close();
                    return;
                }

                errorMessage  = "Win32 Error: ";
                errorMessage += Convert.ToString(Enum.Parse(typeof(LUGAPI.WinError), result.ToString()));
            }

            Logger.ShowUserError(errorMessage);
        }
コード例 #9
0
ファイル: NewGroupDlg.cs プロジェクト: vmware/likewise-open
        public NewGroupDlg(IPlugInContainer container, StandardPage parentPage, Hostinfo hn, IPlugIn plugin)
            : base(container, parentPage)
        {
            InitializeComponent();

            // Create an instance of a ListView column sorter and assign it
            // to the ListView control.
            lvwColumnSorter = new ListViewColumnSorter();
            this.lvMembers.ListViewItemSorter = lvwColumnSorter;

            this.ButtonCancel.Text = "Cancel";

            this.ButtonOK.Text = "Create";

            this.SetAllValueChangedHandlers(this);

            localParent = (LUGPage)parentPage;

            if (localParent == null)
            {
                throw new ArgumentException("NewGroupDlg constructor: (LUGPage) parentPage == null");
            }

            this._hn     = hn;
            this._plugin = (LUGPlugIn)plugin;

            ((EditDialog)this).btnApply.Visible = false;
            users = new Hashtable();

            this.tbGroupName.Select();
        }
コード例 #10
0
        private void acDelete_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            // get the sharename
            ListViewItem Item = GetSelectedItem();

            if (Item == null)
            {
                return;
            }
            string   sShareName = (string)Item.SubItems[0].Text;
            Hostinfo hn         = ctx as Hostinfo;

            // first, prompt for confirmation
            string sMsg = string.Format(Resources.Prompt_DeleteShare, sShareName);

            if (container.Prompt(sMsg, MessageBoxButtons.OKCancel) != DialogResult.OK)
            {
                return;
            }
            // delete and refresh
            if (Configurations.currentPlatform == LikewiseTargetPlatform.Windows)
            {
                SharesAPI.DeleteShare(IntPtr.Zero, hn.creds, hn.hostName, sShareName);
            }
            else
            {
                SharesAPI.DeleteShare(plugin.fileHandle.Handle, hn.creds, hn.hostName, sShareName);
            }

            Refresh();
        }
コード例 #11
0
        private void On_MenuClick(object sender, EventArgs e)
        {
            MenuItem m = sender as MenuItem;

            if (m != null && m.Text.Trim().Equals("&Properties"))
            {
                ListViewItem Item = GetSelectedItem();

                if (Item == null)
                {
                    return;
                }

                string   sShare    = (string)Item.SubItems[0].Text;
                string[] Shareinfo = null;
                Hostinfo hn        = ctx as Hostinfo;

                if (plugin.fileHandle != null)
                {
                    Shareinfo = SharesAPI.GetShareInfo(plugin.fileHandle.Handle, sShare, hn.hostName);
                }
                else
                {
                    Shareinfo = SharesAPI.GetShareInfo(IntPtr.Zero, sShare, hn.hostName);
                }

                if (Shareinfo != null && Shareinfo.Length != 0)
                {
                    if (Shareinfo[0].Equals("share"))
                    {
                        SharePropertiesDlg shareDlg = new SharePropertiesDlg(container, this, plugin, hn);
                        shareDlg.SetData(hn.creds, sShare, Shareinfo);
                        shareDlg.ShowDialog(this);
                    }
                    else
                    {
                        string sMsg = "This has been shared for administrative purposes.\n The Share permissions and file security cannot be set";
                        container.ShowMessage(sMsg);
                    }
                }
            }

            if (m != null && m.Text.Trim().Equals("&Help"))
            {
                ProcessStartInfo psi = new ProcessStartInfo();
                psi.UseShellExecute = true;
                psi.FileName        = CommonResources.GetString("LAC_Help");
                psi.Verb            = "open";
                psi.WindowStyle     = ProcessWindowStyle.Normal;
                Process.Start(psi);
                return;
            }

            if (m != null && m.Text.Trim().Equals("&Refresh"))
            {
                treeNode.sc.ShowControl(treeNode);
            }
        }
コード例 #12
0
        private void enumLUGCallback(LUGAPI.LUGEnumStatus enumStatus)
        {
            Hostinfo hn = ctx as Hostinfo;

            if (enumStatus.entries != null && enumStatus.entries.Count > 0)
            {
                lvArr = new ListViewItem[Convert.ToInt32(enumStatus.entries.Count)];

                for (int i = 0; i < enumStatus.entries.Count; i++)
                {
                    lvArr[i] = new ListViewItem(enumStatus.entries[i]);
                    if (enumStatus.entries[i][1] == LUGAPI.Disabled)
                    {
                        lvArr[i].ImageIndex = (int)imageLUGDisabled;
                    }
                    else
                    {
                        lvArr[i].ImageIndex = (int)imageLUG;
                    }
                }

                this.lvLUGBETA.Items.AddRange(lvArr);

                this.AutoResizePage();

                if (enumStatus.moreEntries)
                {
                    try
                    {
                        if (enumStatus.type == LUGAPI.LUGType.User)
                        {
                            LUGAPI.NetEnumUsers(
                                hn.hostName,
                                enumStatus.resumeHandle,
                                out enumStatus);
                            enumLUGCallback(enumStatus);
                        }
                        else if (enumStatus.type == LUGAPI.LUGType.Group)
                        {
                            LUGAPI.NetEnumGroups(
                                hn.hostName,
                                enumStatus.resumeHandle,
                                out enumStatus);
                            enumLUGCallback(enumStatus);
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.Log(ex.StackTrace);
                    }
                    //container.SetCursor(Cursors.Default);
                }
                else
                {
                    //container.SetCursor(Cursors.Default);
                }
            }
        }
コード例 #13
0
        private void ShowLUGPropertiesDlg()
        {
            Logger.Log("LUGPage.ShowLUGProperties() called", Logger.netAPILogLevel);

            if (memberType == LUGAPI.LUGType.User)
            {
                if (lvLUGBETA.SelectedItems.Count != 1)
                {
                    return;
                }

                ListViewItem item = lvLUGBETA.SelectedItems[0];
                string       user = item.SubItems[2].Text;

                Logger.Log(String.Format("LUGPage.ShowLUGProperties() user={0}", user), Logger.netAPILogLevel);

                try
                {
                    UserPropertiesDlg lugDlg = new UserPropertiesDlg(container, this);
                    Hostinfo          hn     = ctx as Hostinfo;

                    lugDlg.SetData(hn.creds, hn.hostName, user);

                    lugDlg.ShowDialog();
                }
                catch (Exception e)
                {
                    Logger.LogException("LUGPage.ShowLUGPropertiesDlg (user)", e);
                }
            }
            else if (memberType == LUGAPI.LUGType.Group)
            {
                if (lvLUGBETA.SelectedItems.Count != 1)
                {
                    return;
                }

                try
                {
                    ListViewItem item = lvLUGBETA.SelectedItems[0];

                    string group = item.SubItems[1].Text;

                    Logger.Log(String.Format("LUGPage.ShowLUGProperties() group={0}", group), Logger.netAPILogLevel);

                    GroupPropertiesDlg gpDlg = new GroupPropertiesDlg(this.container, this, pi);
                    Hostinfo           hn    = ctx as Hostinfo;
                    gpDlg.SetData(hn.creds, hn.hostName, group);
                    gpDlg.ShowDialog();
                }
                catch (Exception e)
                {
                    Logger.LogException("LUGPage.ShowLUGPropertiesDlg (group)", e);
                }
            }
        }
コード例 #14
0
        public override void Refresh()
        {
            base.Refresh();

            const int NUM_COLUMNS = 6;

            //pixels to use to give a visible margin between columns
            const int MARGIN = 10;

            Hostinfo hn = ctx as Hostinfo;

            if (!String.IsNullOrEmpty(hn.hostName))
            {
                this.lblCaption.Text = string.Format(this.lblCaption.Text, hn.hostName);
            }

            if (lvSessionPage.Items.Count != 0)
            {
                lvSessionPage.Items.Clear();
            }

            Dictionary <int, string[]> SessionList = Session.EnumSessions(hn.creds, hn.hostName);

            if (SessionList == null)
            {
                Logger.Log("SessionPage.Refresh: SessionList == null");
                return;
            }

            foreach (int i in SessionList.Keys)
            {
                ListViewItem lvItem = new ListViewItem(SessionList[i]);
                lvSessionPage.Items.Add(lvItem);
            }

            int minColumnWidth = (this.Width / NUM_COLUMNS) / 2;

            foreach (ColumnHeader ch in lvSessionPage.Columns)
            {
                if (ch.Index != 0)
                {
                    if (ch.Width + MARGIN < minColumnWidth)
                    {
                        ch.Width = minColumnWidth;
                    }
                    else
                    {
                        ch.Width += MARGIN;
                    }
                }
            }

            //HACK: make sure that rightmost column is always covers
            //any remaining space on the right side of the list view
            lvSessionPage.Columns[NUM_COLUMNS - 1].Width = this.Width;
        }
コード例 #15
0
        private void cbLog_SelectedIndexChanged(object sender, EventArgs e)
        {
            Hostinfo hn = ctx as Hostinfo;

            lvLUGBETA.Items.Clear();

            LUGAPI.LUGEnumStatus enumStatus;
            enumLUG(hn.hostName, 0, out enumStatus);
            enumLUGCallback(enumStatus);
        }
コード例 #16
0
 public void EnumChildren(LACTreeNode parentNode)
 {
     Logger.Log("EventlogPlugin.EnumChildren", Logger.eventLogLogLevel);
     if (_pluginNode != null && parentNode == _pluginNode && Hostinfo.HasCreds(_hn))
     {
         EventViewerControl eventlogPage = (EventViewerControl)_pluginNode.PluginPage;
         eventlogPage.LoadData(EventViewerControl.EventViewerNodeType.PLUGIN);
     }
     return;
 }
コード例 #17
0
ファイル: FilesPage.cs プロジェクト: vmware/likewise-open
        public override void SetPlugInInfo(IPlugInContainer container, IPlugIn pi, LACTreeNode treeNode, LWTreeView lmctreeview, CServerControl sc)
        {
            Hostinfo hn = ctx as Hostinfo;

            base.SetPlugInInfo(container, pi, treeNode, lmctreeview, sc);
            bEnableActionMenu = false;
            plugin            = pi as FileShareManagerIPlugIn;
            hn = plugin.HostInfo;

            Refresh();
        }
コード例 #18
0
        public SharePropertiesDlg(IPlugInContainer container, StandardPage parentPage, FileShareManagerIPlugIn plugin, Hostinfo hn)
            : base(container, parentPage)
        {
            InitializeComponent();

            this.Text  = "{0} Properties";
            this._hn   = hn;
            _plugin    = plugin;
            _container = container;
            InitializePages();
        }
コード例 #19
0
        private void On_MenuClick(object sender, EventArgs e)
        {
            MenuItem m = sender as MenuItem;

            if (m != null && m.Text.Trim().Equals("&Help"))
            {
                ProcessStartInfo psi = new ProcessStartInfo();
                psi.UseShellExecute = true;
                psi.FileName        = CommonResources.GetString("LAC_Help");
                psi.Verb            = "open";
                psi.WindowStyle     = ProcessWindowStyle.Normal;
                Process.Start(psi);
                return;
            }

            if (m != null && m.Text.Trim().Equals("&Refresh"))
            {
                treeNode.sc.ShowControl(treeNode);
            }

            if (m != null && m.Text.Trim().Equals("Disconnect &All Sessions"))
            {
                DialogResult dlg = MessageBox.Show(this, "Are you sure you wish to close all sessions?",
                                                   CommonResources.GetString("Caption_Console"),
                                                   MessageBoxButtons.YesNo, MessageBoxIcon.None,
                                                   MessageBoxDefaultButton.Button1);

                if (dlg == DialogResult.OK)
                {
                    foreach (ListViewItem Item in lvSessionPage.Items)
                    {
                        string sUserMachine = (string)Item.SubItems[1].Text;
                        string sUser        = (string)Item.SubItems[0].Text;

                        try
                        {
                            Hostinfo hn = ctx as Hostinfo;
                            Session.DeleteSession(hn.creds, hn.hostName, sUserMachine, sUser);
                        }
                        catch (Exception ex)
                        {
                            string sMsg = string.Format(Resources.Error_DeleteSessionError, ex.Message);
                            container.ShowError(sMsg);
                            break;
                        }
                    }
                    //Just do refresh once the files got closed on the treenode.
                    treeNode.sc.ShowControl(treeNode);
                }
            }
        }
コード例 #20
0
ファイル: NewUserDlg.cs プロジェクト: vmware/likewise-open
        protected override bool Apply(EditDialogAction actionCause)
        {
            uint   result       = (uint)LUGAPI.WinError.ERROR_SUCCESS;
            string errorMessage = null;

            try
            {
                if (!Hostinfo.ValidatePassword(tbConfirmPassword.Text, tbPassword.Text, out errorMessage))
                {
                    if (!(tbConfirmPassword.Text.Trim().Equals(tbPassword.Text)))
                    {
                        errorMessage = "The password was not correctly confirmed. Please ensure that the password and confirmation match exactly";
                    }
                    container.ShowError(errorMessage, MessageBoxButtons.OK);
                    return(false);
                }

                Password     = tbPassword.Text;
                User         = tbUserName.Text;
                FullName     = tbFullName.Text;
                Description  = tbDescription.Text;
                CannotChange = cbCannotChange.Checked;
                MustChange   = cbMustChange.Checked;
                NeverExpires = cbNeverExpires.Checked;
                IsDisabled   = cbIsDisabled.Checked;

                LUGPage lugPg = localParent;

                if (lugPg == null)
                {
                    Logger.Log("NewUserDlg.Apply  localParent == null", Logger.LogLevel.Error);
                    return(false);
                }

                result = lugPg.AddLUG(this);

                if (result != (uint)LUGAPI.WinError.ERROR_SUCCESS)
                {
                    container.ShowError(
                        "Likewise Administrative Console encountered an error when trying to add a new user.  " + ErrorCodes.WIN32String((int)result),
                        MessageBoxButtons.OK);
                    return(false);
                }
            }
            catch (Exception e)
            {
                Logger.LogException("NewUserDlg.Apply", e);
            }

            return(true);
        }
コード例 #21
0
 public void DeserializePluginInfo(XmlNode node, ref LACTreeNode pluginNode, string nodepath)
 {
     try
     {
         Hostinfo _hn = GetContext() as Hostinfo;
         Manage.DeserializeHostInfo(node, ref pluginNode, nodepath, ref _hn, false);
         pluginNode.Text = this.GetName();
         pluginNode.Name = this.GetName();
     }
     catch (Exception ex)
     {
         Logger.LogException("ServiceManagerPlugin.DeserializePluginInfo()", ex);
     }
 }
コード例 #22
0
        public static void GetPluginCredentials(IPlugIn plugin, Hostinfo hn)
        {
            _plugin = plugin;
            _hn     = hn;

            if (IsConnectSetBefore(plugin))
            {
                GetConnectedHostInfoFromIni(_plugin, _hn);
            }
            else
            {
                SetDefaultCredentails();
            }
        }
コード例 #23
0
        private void acClose_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (lvSessionPage.SelectedItems.Count != 1)
            {
                return;
            }

            // get the accessing machine and user name of the session to close
            ListViewItem Item         = lvSessionPage.SelectedItems[0];
            string       sUserMachine = (string)Item.SubItems[1].Text;
            string       sUser        = (string)Item.SubItems[0].Text;
            Hostinfo     hn           = ctx as Hostinfo;

            Session.DeleteSession(hn.creds, hn.hostName, sUserMachine, sUser);

            treeNode.sc.ShowControl(treeNode);
        }
コード例 #24
0
        private void cm_OnConnect(object sender, EventArgs e)
        {
            //check if we are joined to a domain -- if not, use simple bind
            uint requestedFields = (uint)Hostinfo.FieldBitmaskBits.FQ_HOSTNAME;

            //string domainFQDN = null;

            if (_hn == null)
            {
                _hn = new Hostinfo();
            }

            //TODO: kerberize eventlog, so that creds are meaningful.
            //for now, there's no reason to attempt single sign-on
            requestedFields |= (uint)Hostinfo.FieldBitmaskBits.FORCE_USER_PROMPT;


            if (_hn != null)
            {
                if (!_container.GetTargetMachineInfo(this, _hn, requestedFields))
                {
                    Logger.Log(
                        "Could not find information about target machine",
                        Logger.eventLogLogLevel);
                    if (eventLogHandle != null)
                    {
                        _hn.IsConnectionSuccess = true;
                    }
                }
                else
                {
                    if (_pluginNode != null && !String.IsNullOrEmpty(_hn.hostName))
                    {
                        logs = null;

                        if (eventLogHandle == null)
                        {
                            _container.ShowError("Unable to open the event log; eventlog server may be disabled");
                            _pluginNode.sc.ShowControl(_pluginNode);
                        }
                    }
                }
            }
        }
コード例 #25
0
        /// <summary>
        /// If HostInfo is not null,lists the all child nodes on click of any node in left hand pane of ADUC
        /// </summary>
        /// <param name="parentNode"></param>
        public void EnumChildren(LACTreeNode parentNode)
        {
            Logger.Log("ADUCPlugin.EnumChildren", Logger.manageLogLevel);

            if (!Hostinfo.HasCreds(_hn))
            {
                //attempt to retrieve host info information from kerberos
                Hostinfo defaultHostInfo = new Hostinfo();

                //assume for now that the AD hostname is the same as the LDAP domain
                defaultHostInfo.creds.MachineName = defaultHostInfo.domainName;
                defaultHostInfo.hostName          = defaultHostInfo.domainName;

                Logger.Log(defaultHostInfo.domainName, Logger.manageLogLevel);

                //LDAP is not yet kerberized, so set password to null to make sure the user gets prompted
                defaultHostInfo.creds.Password = null;
            }
        }
コード例 #26
0
        /// <summary>
        /// Method that creates and initializes the ADUC Rootnode
        /// </summary>
        /// <returns></returns>
        private LACTreeNode GetADUCRootNode()
        {
            Logger.Log("ADUCPlugin.GetADUCRootNode", Logger.manageLogLevel);

            if (_pluginNode == null)
            {
                _hn         = new Hostinfo();
                _pluginNode = Manage.CreateIconNode(Resources.ADUCTitle,
                                                    Resources.ADUC,
                                                    typeof(ADUCPage),
                                                    this);
                _pluginNode.IsPluginNode = true;
            }
            _pluginNode.ImageIndex         = (int)Manage.ManageImageType.Generic;
            _pluginNode.SelectedImageIndex = (int)Manage.ManageImageType.Generic;


            return(_pluginNode);
        }
コード例 #27
0
        public void SetContext(IContext ctx)
        {
            Hostinfo hn = ctx as Hostinfo;

            Logger.Log(String.Format("FileShareManagerPlugIn.SetHost(hn: {0}\n)",
                                     hn == null ? "<null>" : hn.ToString()), Logger.eventLogLogLevel);

            bool deadTree = false;

            if (_pluginNode != null &&
                _pluginNode.Nodes != null &&
                _hn != null &&
                hn != null &&
                hn.hostName !=
                _hn.hostName)
            {
                foreach (TreeNode node in _pluginNode.Nodes)
                {
                    _pluginNode.Nodes.Remove(node);
                }
                deadTree = true;
            }

            _hn = hn;

            if (HostInfo == null)
            {
                _hn = new Hostinfo();
            }

            ConnectToHost();

            if (_pluginNode != null && _pluginNode.Nodes.Count == 0 && _hn.IsConnectionSuccess)
            {
                BuildNodesToPlugin();
            }

            if (deadTree && _pluginNode != null)
            {
                _pluginNode.SetContext(_hn);
            }
        }
コード例 #28
0
        private void SetListviewColumns()
        {
            if (lvSharePage.Columns.Count != 0)
            {
                lvSharePage.Columns.Clear();
            }

            if (nodeType == FileShareManagerIPlugIn.PluginNodeType.UNDEFINED)
            {
                this.lvSharePage.MultiSelect = false;
                this.lblCaption.Text         = "Select shared folders to view";
                columnLabels = new string[] { "Name" };
            }
            else if (nodeType == FileShareManagerIPlugIn.PluginNodeType.SHARES)
            {
                Hostinfo hn = ctx as Hostinfo;

                this.lvSharePage.MultiSelect = true;

                if (!String.IsNullOrEmpty(hn.hostName))
                {
                    this.lblCaption.Text = string.Format(this.lblCaption.Text, hn.hostName);
                }
                columnLabels = new string[] { "Share", "Path", "Description", "Current Users" };
            }
            else
            {
                throw new ArgumentException("SharesPage must be initialized as either FileShareManagerIPlugIn.PluginNodeType.SHARES, " +
                                            "FileShareManagerIPlugIn.PluginNodeType.UNDEFINED, but was not");
            }

            numColumns    = columnLabels.Length;
            columnHeaders = new ColumnHeader[numColumns];
            for (int i = 0; i < numColumns; i++)
            {
                columnHeaders[i]       = new ColumnHeader();
                columnHeaders[i].Text  = columnLabels[i];
                columnHeaders[i].Width = 125;
            }

            this.lvSharePage.Columns.AddRange(columnHeaders);
        }
コード例 #29
0
        private void SetPasswordDlg()
        {
            Logger.Log("LUGPage.SetPassword() called", Logger.netAPILogLevel);

            if (lvLUGBETA.SelectedItems.Count != 1)
            {
                return;
            }

            ChangePasswordDlg cpDlg = new ChangePasswordDlg();

            ListViewItem item = lvLUGBETA.SelectedItems[0];
            string       user = item.SubItems[2].Text;
            Hostinfo     hn   = ctx as Hostinfo;

            cpDlg.UserName = user;
            cpDlg.HostName = hn.hostName;

            cpDlg.ShowDialog();
        }
コード例 #30
0
        private void ShowRenameDlg()
        {
            Logger.Log("LUGPage.Rename() called", Logger.netAPILogLevel);

            if (lvLUGBETA.SelectedItems.Count != 1)
            {
                return;
            }

            try
            {
                ListViewItem item      = lvLUGBETA.SelectedItems[0];
                Hostinfo     hn        = ctx as Hostinfo;
                RenameDlg    renameDlg = new RenameDlg();

                renameDlg.HostName = hn.hostName;

                if (memberType == LUGAPI.LUGType.User)
                {
                    renameDlg.IsUser  = true;
                    renameDlg.Text    = "Rename User";
                    renameDlg.OldName = item.SubItems[2].Text;
                }
                else if (memberType == LUGAPI.LUGType.Group)
                {
                    renameDlg.IsUser  = false;
                    renameDlg.Text    = "Rename Group";
                    renameDlg.OldName = item.SubItems[1].Text;
                }

                if (renameDlg.ShowDialog() == DialogResult.OK)
                {
                    Refresh();
                }
            }
            catch (Exception except)
            {
                container.ShowError(except.Message);
            }
        }