public FilterBarViewModel(TicketCenterListSettings listPreferences, UserInfo[] staffUsers, UserInfo[] submitterUsers)
 {
     Preferences = listPreferences;
     StaffUsers = staffUsers;
     SubmitterUsers = submitterUsers;
 }
示例#2
0
        internal UserInfo[] GetGroupMembersFromAd(string groupName)
        {
            UserInfo[] usersInGroup = null;
            using
            (
                PrincipalContext ctx = new PrincipalContext(ContextType.Domain,
                                        GetActiveDirectoryDomain(),
                                        GetActiveDirectoryUser(),
                                        GetActiveDirectoryUserPassword())
            )
            {

                using (GroupPrincipal grp = GroupPrincipal.FindByIdentity(ctx, IdentityType.SamAccountName, groupName.ToLowerInvariant()))
                {
                    if (grp != null)
                    {
                        var x = from p in grp.GetMembers(true)
                                where p.StructuralObjectClass == "user" &&
                                      !string.IsNullOrEmpty(p.UserPrincipalName) &&
                                      !string.IsNullOrEmpty(p.DisplayName) &&
                                      p.UserPrincipalName.Trim() != string.Empty &&
                                      p.DisplayName.Trim() != string.Empty
                                orderby p.DisplayName
                                select new UserInfo() { Name = p.SamAccountName.ToLowerInvariant(), DisplayName = p.DisplayName };

                        usersInGroup = x.ToArray();
                    }
                    else
                    {
                        usersInGroup = new UserInfo[0];//zero length array for memory cache, so it doesn't attempt re-fetches
                    }
                }
            }
            return usersInGroup;
        }