Ejemplo n.º 1
0
        public IEnumerable <DtUser> GetAllUsers(out int sequence)
        {
            var offset  = 0;
            var hasMore = true;
            var result  = new List <DtUser>();

            do
            {
                var jarray   = new JArray(client.GetDocument(WaadConfig.UserApiFullName, offset, ReadLimit));
                var arr      = JObject.Parse(jarray[0].Value <string>());
                var contents = arr["contents"].Value <JArray>();
                sequence = arr["seq"].Value <int>();

                foreach (var row in contents)
                {
                    var datarow = new DtUser().FromContentRow(row);
                    result.Add(datarow);
                }

                if (contents.Count < ReadLimit)
                {
                    hasMore = false;
                }
                else
                {
                    offset += ReadLimit;
                }
            } while (hasMore);

            return(result);
        }
Ejemplo n.º 2
0
        public void CreateUser(ref DtUser dtUser)
        {
            dtUser.AdUsername = GetFreshUsername(dtUser.Username);
            var user = new AdUser();

            user.displayName       = dtUser.DisplayName;
            user.userPrincipalName = dtUser.AdUsername;
            user.mailNickname      = dtUser.MailNickname;
            user.accountEnabled    = true;

            var pwProfile = new PasswordProfile();

            pwProfile.password = WaadConfig.DefaultPassword;
            pwProfile.forceChangePasswordNextLogin = true;
            user.passwordProfile = pwProfile;

            if (dtUser.HasAlternateEmail)
            {
                user.otherMails.Add(dtUser.Username);
            }

            directoryDataService.AddTousers(user);

            directoryDataService.SaveChanges();
        }
Ejemplo n.º 3
0
        public IDataResult <DtUser> CreateUser(CreateUserRequest request)
        {
            if (_userDal.Get(x => x.Email == request.Email).FirstOrDefault() != null)
            {
                return(new ErrorDataResult <DtUser>(MessageConstants.ThisEmailIsUsingAlready));
            }

            var user = new DtUser();

            user.BirthDate     = request.BirthDate;
            user.DeviceId      = request.DeviceId;
            user.Email         = request.Email;
            user.Firstname     = request.Firstname;
            user.IsActive      = false;
            user.IsApproved    = false;
            user.IsTransferred = false;
            user.Lastname      = request.Lastname;
            user.RegisterDate  = DateTime.Now;

            var decryptedClientPassword = Encryption.Decrypt(request.Password, EncryptionConstants.ClientEncryptionKey);

            user.Password = Encryption.Encrypt(decryptedClientPassword, EncryptionConstants.ServerEncryptionKey);

            return(new SuccessDataResult <DtUser>(_userDal.AddAsync(user).Result));
        }
Ejemplo n.º 4
0
        public bool UpdateUser(DtUser user)
        {
            AdUser refreshedUser = directoryDataService.directoryObjects.OfType <AdUser>().Where(it => (it.userPrincipalName == user.AdUsername)).SingleOrDefault();

            if (refreshedUser == null)
            {
                return(false);
            }

            refreshedUser.displayName = user.DisplayName;
            directoryDataService.UpdateObject(refreshedUser);
            directoryDataService.SaveChanges(System.Data.Services.Client.SaveChangesOptions.PatchOnUpdate);
            return(true);
        }