Ejemplo n.º 1
0
        public uint AddLUG(object o)
        {
            uint result = (uint)LUGAPI.WinError.ERROR_SUCCESS;

            try
            {
                if (memberType == LUGAPI.LUGType.User)
                {
                    NewUserDlg nu = (NewUserDlg)o;
                    if (nu != null)
                    {
                        Logger.Log(String.Format("LUGPage.AddLUG mustChange={0}, cannotChange={1}, isDisabled={2}, neverExpires={3}",
                                                 nu.MustChange, nu.CannotChange, nu.IsDisabled, nu.NeverExpires));

                        uint     flags = LUGAPI.UF_SCRIPT;
                        Hostinfo hn    = ctx as Hostinfo;

                        flags |= nu.MustChange ? LUGAPI.UF_PASSWORD_EXPIRED : 0;

                        flags |= nu.CannotChange ? LUGAPI.UF_PASSWD_CANT_CHANGE : 0;

                        flags |= nu.IsDisabled ? LUGAPI.UF_ACCOUNTDISABLE : 0;

                        flags |= nu.NeverExpires ? LUGAPI.UF_DONT_EXPIRE_PASSWD : 0;

                        result = LUGAPI.NetAddUser(
                            hn.hostName,
                            nu.User,
                            nu.Password,
                            nu.FullName,
                            nu.Description,
                            flags);

                        if (result == (uint)LUGAPI.WinError.ERROR_SUCCESS)
                        {
                            string[] row = new string[] { "", nu.IsDisabled ? "Disabled" : "", nu.User, nu.FullName, nu.Description };
                            InsertLUGToListView(row);
                            return(result);
                        }
                    }
                }
                else if (memberType == LUGAPI.LUGType.Group)
                {
                    NewGroupDlg ng = (NewGroupDlg)o;
                    Hostinfo    hn = ctx as Hostinfo;
                    if (ng != null)
                    {
                        result = LUGAPI.NetAddGroup(
                            hn.hostName,
                            ng.GroupName,
                            ng.Description);

                        if (result == (uint)LUGAPI.WinError.ERROR_SUCCESS)
                        {
                            string[] row = new string[] { "", ng.GroupName, ng.Description };
                            InsertLUGToListView(row);
                            return(result);
                        }
                    }
                }
            }
            catch (Exception)
            {
                result = (uint)LUGAPI.WinError.ERROR_EXCEPTION_IN_SERVICE;
            }
            return(result);
        }