Esempio n. 1
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);
                }
            }
        }
Esempio n. 2
0
        public bool EditLUG(object o)
        {
            bool retValue = false;

            try
            {
                if (memberType == LUGAPI.LUGType.User)
                {
                    UserProperties up = ((UserPropertiesDlg)o).userProperties;
                    Hostinfo       hn = ctx as Hostinfo;

                    uint flags = 0;

                    LUGAPI.LUGInfo userInfo;
                    LUGAPI.NetGetUserInfo(hn.hostName, up.userName, out userInfo);

                    flags = userInfo.flags;

                    uint old_flags = userInfo.flags;

                    Logger.Log(String.Format("LUGPage.EditLUG(user): flags: expired:{0}, cant_change:{1}, never_expires:{2}, disabled:{3}, lockout:{4}, old_flags: {5}",
                                             up.mustChange,
                                             up.cannotChange,
                                             up.neverExpires,
                                             up.isDisabled,
                                             up.isLocked,
                                             LUGAPI.flagDescription(flags)), Logger.netAPILogLevel);

                    // Clear flags we are interested in...
                    flags &= ~(LUGAPI.UF_PASSWORD_EXPIRED);
                    flags &= ~(LUGAPI.UF_PASSWD_CANT_CHANGE);
                    flags &= ~(LUGAPI.UF_DONT_EXPIRE_PASSWD);
                    flags &= ~(LUGAPI.UF_ACCOUNTDISABLE);
                    flags &= ~(LUGAPI.UF_LOCKOUT);

                    // Set flags per user request...
                    flags |= up.mustChange ? LUGAPI.UF_PASSWORD_EXPIRED : 0;
                    flags |= up.cannotChange ? LUGAPI.UF_PASSWD_CANT_CHANGE : 0;
                    flags |= up.isDisabled ? LUGAPI.UF_ACCOUNTDISABLE : 0;
                    flags |= up.neverExpires ? LUGAPI.UF_DONT_EXPIRE_PASSWD : 0;
                    flags |= up.isLocked ? LUGAPI.UF_LOCKOUT : 0;

                    Logger.Log(String.Format("LUGPage.EditLUG(user) new_flags: {0}",
                                             LUGAPI.flagDescription(flags)), Logger.netAPILogLevel);

                    if (userInfo.fullname != up.fullName)
                    {
                        LUGAPI.NetEditUserFullName(hn.hostName, up.userName, up.fullName);
                    }

                    if (userInfo.description != up.description)
                    {
                        LUGAPI.NetEditUserDescription(hn.hostName, up.userName, up.description);
                    }

                    if (old_flags != flags)
                    {
                        LUGAPI.NetEditUserFlags(hn.hostName, up.userName, flags);
                    }

                    retValue = true;


                    Refresh();
                }
                else if (memberType == LUGAPI.LUGType.Group)
                {
                    GroupPropertiesDlg gpDlg = (GroupPropertiesDlg)o;
                    Hostinfo           hn    = ctx as Hostinfo;

                    if (gpDlg != null)
                    {
                        string description;

                        LUGAPI.NetGetGroupInfo(
                            hn.hostName,
                            gpDlg.GroupName,
                            out description
                            );

                        if (description == null || description != gpDlg.Description)
                        {
                            LUGAPI.NetEditGroupDescription(hn.hostName, gpDlg.GroupName, gpDlg.Description);
                            Refresh();
                        }
                    }
                }
            }
            catch (Exception e)
            {
                retValue = false;
                Logger.LogException("EditLUG", e);
            }

            return(retValue);
        }