示例#1
0
        public async Task <IActionResult> Edit(string id, [Bind("LocalGroupID,GroupName,GroupDescription,LocalUserID")] LocalGroup localGroup)
        {
            if (id != localGroup.LocalGroupID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(localGroup);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LocalGroupExists(localGroup.LocalGroupID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["LocalUserID"] = new SelectList(_context.LocalUser, "LocalUserID", "LocalUserID", localGroup.LocalUserID);
            return(View(localGroup));
        }
            public bool MoveNext()
            {
                if (_position >= _uniqueKeys.Length)
                {
                    return(false);
                }

                var currentKey = _uniqueKeys.Get(_position);

                var groupLocalList = new LocalList <T>();

                for (var i = 0; i < _values.Length; i++)
                {
                    var value = _values.Get(i);
                    if (_comparer.Equals(currentKey, value.Key))
                    {
                        groupLocalList.Add(value.Value);
                    }
                }

                _current = new LocalGroup(currentKey, groupLocalList);
                _position++;

                return(true);
            }
示例#3
0
        public async Task <IActionResult> Create([Bind("LocalGroupID,GroupName,GroupDescription,LocalUserID")] LocalGroup localGroup)
        {
            if (ModelState.IsValid)
            {
                _context.Add(localGroup);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["LocalUserID"] = new SelectList(_context.LocalUser, "LocalUserID", "LocalUserID", localGroup.LocalUserID);
            return(View(localGroup));
        }
        public ActionResult <IEnumerable <GroupChat> > GroupChat([FromQuery] Guid Fk_Group)
        {
            if (Fk_Group.ToString() == "")
            {
                return(BadRequest());
            }
            LocalGroup lg = db.LocalGroup.Include(p => p.Messages).ThenInclude(p => p.Author).ThenInclude(p => p.Avatar)
                            .Include(p => p.Messages).ThenInclude(p => p.Image).FirstOrDefault(p => p.Uid == Fk_Group);

            if (lg == null)
            {
                return(BadRequest());
            }
            return(lg.Messages.OrderByDescending(p => p.CreatedAt).ToList());
        }
        public LocalGroup GetLocalGroupById(int lgid)
        {
            var db = new EstiemPortalContext();

            // Todo: Update this when changing to new db schema.
            // Add Region as string to table
            // Possibly add API here, functions still the same
            LocalGroup lg = (from m in db.ESTIEM_LocalGroup
                             where m.Id == lgid
                             select new LocalGroup
            {
                //Populate LG Function?
                Id = m.Id,
                Name = m.Name
            }).FirstOrDefault();

            return(lg);
        }
            internal GroupEnumerator(LocalList <T> list, Func <T, TKey> keySelector, EqualityComparer <TKey> comparer)
            {
                var values     = new LocalList <Row <TKey, T> >(list.Length);
                var uniqueKeys = new LocalList <TKey>();

                for (var i = 0; i < list.Length; i++)
                {
                    var element = list.Get(i);
                    var key     = keySelector(element);

                    values.Add(new Row <TKey, T>(key, element));

                    if (!uniqueKeys.Contains(key, comparer))
                    {
                        uniqueKeys.Add(key);
                    }
                }

                _comparer   = comparer;
                _current    = default;
                _position   = 0;
                _values     = values;
                _uniqueKeys = uniqueKeys;
            }
示例#7
0
    public MachinePermissions()
    {
        machineName = Environment.MachineName;
        PrincipalContext ctx = new PrincipalContext(ContextType.Machine, Environment.MachineName);
        GroupPrincipal   gp  = new GroupPrincipal(ctx);

        gp.Name = "*";
        PrincipalSearcher ps = new PrincipalSearcher();

        ps.QueryFilter = gp;
        PrincipalSearchResult <Principal> result = ps.FindAll();

        if (result.Count() > 0)
        {
            localGroups = new List <LocalGroup>();
            foreach (Principal p in result)
            {
                LocalGroup g = new LocalGroup();
                g.groupName = p.Name;
                g.users     = GetGroupMembers(g.groupName);
                localGroups.Add(g);
            }
        }
    }
 private ADAllowableInputObject(LocalGroup group)
 {
     this.LoginName = group.Name;
     this.IsLocal   = true;
     this.Type      = LoginType.WindowsGroup;
 }
示例#9
0
        public static IEnumerable <object> Get_NetLocalGroup(Args_Get_NetLocalGroup args = null)
        {
            if (args == null)
            {
                args = new Args_Get_NetLocalGroup();
            }

            var LogonToken = IntPtr.Zero;

            if (args.Credential != null)
            {
                LogonToken = InvokeUserImpersonation.Invoke_UserImpersonation(new Args_Invoke_UserImpersonation
                {
                    Credential = args.Credential
                });
            }

            var LocalGroups = new List <object>();

            foreach (var Computer in args.ComputerName)
            {
                if (args.Method == MethodType.API)
                {
                    // if we're using the Netapi32 NetLocalGroupEnum API call to get the local group information
                    // arguments for NetLocalGroupEnum
                    var QueryLevel   = 1;
                    var PtrInfo      = IntPtr.Zero;
                    var EntriesRead  = 0;
                    var TotalRead    = 0;
                    var ResumeHandle = 0;

                    // get the local user information
                    var Result = NativeMethods.NetLocalGroupEnum(Computer, QueryLevel, out PtrInfo, MAX_PREFERRED_LENGTH, out EntriesRead, out TotalRead, ref ResumeHandle);

                    // locate the offset of the initial intPtr
                    var Offset = PtrInfo.ToInt64();

                    // 0 = success
                    if ((Result == 0) && (Offset > 0))
                    {
                        // Work out how much to increment the pointer by finding out the size of the structure
                        var Increment = Marshal.SizeOf(typeof(LOCALGROUP_INFO_1));

                        // parse all the result structures
                        for (var i = 0; (i < EntriesRead); i++)
                        {
                            // create a new int ptr at the given offset and cast the pointer as our result structure
                            var NewIntPtr = new System.IntPtr(Offset);
                            var Info      = (LOCALGROUP_INFO_1)Marshal.PtrToStructure(NewIntPtr, typeof(LOCALGROUP_INFO_1));

                            LocalGroups.Add(new LocalGroupAPI
                            {
                                ComputerName = Computer,
                                GroupName    = Info.lgrpi1_name,
                                Comment      = Info.lgrpi1_comment
                            });
                            Offset  = NewIntPtr.ToInt64();
                            Offset += Increment;
                        }
                        // free up the result buffer
                        NativeMethods.NetApiBufferFree(PtrInfo);
                    }
                    else
                    {
                        Logger.Write_Verbose($@"[Get-NetLocalGroup] Error: {new System.ComponentModel.Win32Exception((int)Result).Message}");
                    }
                }
                else
                {
                    // otherwise we're using the WinNT service provider
                    var ComputerProvider = new System.DirectoryServices.DirectoryEntry($@"WinNT://{Computer},computer");
                    foreach (System.DirectoryServices.DirectoryEntry LocalGroup in ComputerProvider.Children)
                    {
                        if (LocalGroup.SchemaClassName.Equals("group", StringComparison.OrdinalIgnoreCase))
                        {
                            var Group = new LocalGroupWinNT
                            {
                                ComputerName = Computer,
                                GroupName    = LocalGroup.Name,
                                SID          = new System.Security.Principal.SecurityIdentifier((byte[])LocalGroup.InvokeGet("objectsid"), 0).Value,
                                Comment      = LocalGroup.InvokeGet("Description").ToString()
                            };
                            LocalGroups.Add(Group);
                        }
                    }
                }
            }

            if (LogonToken != IntPtr.Zero)
            {
                InvokeRevertToSelf.Invoke_RevertToSelf(LogonToken);
            }
            return(LocalGroups);
        }
        public IEnumerable <Advert> Get([FromQuery] Guid Fk_Group)
        {
            LocalGroup lg = db.LocalGroup.Include(p => p.Adverts).ThenInclude(a => a.Votings).FirstOrDefault(p => p.Uid == Fk_Group);

            return(lg.Adverts.OrderByDescending(p => p.CreatedAt).ToList().Take(50));
        }
 public void CreateLocalGroup(LocalGroup lg)
 {
     //Not used too much to be done later.
 }
 public void EditLocalGroup(LocalGroup lg)
 {
 }
示例#13
0
 internal LocalGroupMembers(LocalGroup localGroup) => this.localGroup = localGroup;