コード例 #1
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);
        }