Example #1
0
        public void GetEmptyDirectoryUsersTest()
        {
            Expect.Call(directoryReaderMock.GetUsers()).Return(new List <DirectoryUser>());

            mockRepository.ReplayAll();

            Assert.IsEmpty((ICollection)managerMock.GetDirectoryUsers().Keys);

            mockRepository.VerifyAll();
        }
Example #2
0
        public IDictionary <string, User> GetDirectoryUsers()
        {
            IDictionary <string, User> users = new Dictionary <string, User>();

            try {
                IList <DirectoryUser> directoryUsers = _directoryReader.GetUsers();

                logger.Info(directoryUsers.Count + " directory members retrieved.");

                //Get the Ldapuser data into a Provisioning.User collection.
                foreach (DirectoryUser directoryUser in directoryUsers)
                {
                    string userName = directoryUser.Username.ToLowerInvariant();

                    if (!users.ContainsKey(userName))
                    {
                        User user = new User();
                        user.Username = directoryUser.Username;
                        user.FullName = directoryUser.FullName;
                        user.Email    = directoryUser.Email;
                        user.Nickname = directoryUser.Nickname;
                        users.Add(userName, user);

                        logger.Debug("Member retrieved from directory: " + user.Username);
                    }
                    else
                    {
                        logger.Error("Duplicate username found in directory: " + directoryUser.Username +
                                     "; ignoring user with duplicate username.");
                    }
                }
            } catch (Exception ex) {
                logger.ErrorException("Error retrieving users from Directory", ex);
                throw;
            }
            return(users);
        }