Example #1
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            try
            {
                var userCreator = new UserService(Credential.UserName, Credential.Password.ToUnsecureString(), ServiceUrl, MessageHandler, ProgressHandler);

                if (String.IsNullOrEmpty(Password))
                {
                    WriteObject(userCreator.CreateUser(Username));
                }
                else
                {
                    userCreator.CreateUserWithPassword(Username, Password);
                }
            }
            catch (AggregateException ae)
            {
                this.WriteErrorsAndThrowOnLast(ae.Flatten().InnerExceptions.Select(LazyCreateError));
            }
            catch (Exception e)
            {
                ThrowTerminatingError(LazyCreateError(e));
            }
        }
Example #2
0
 protected override void ProcessRecord()
 {
     base.ProcessRecord();
     try
     {
         var userService = new UserService(Credential.UserName, Credential.Password.ToUnsecureString(),
                                           ServiceUrl, MessageHandler, ProgressHandler);
         WriteObject(userService.GetRoles(), true);
     }
     catch (AggregateException ae)
     {
         this.WriteErrorsAndThrowOnLast(ae.Flatten().InnerExceptions.Select(LazyCreateError));
     }
     catch (Exception e)
     {
         ThrowTerminatingError(LazyCreateError(e));
     }
 }
Example #3
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            try
            {
                var userService = new UserService(ServiceUrl, MessageHandler,
                                                  ProgressHandler);
                userService.Initialize(UserName, Password);
            }
            catch (AggregateException ae)
            {

                this.WriteErrorsAndThrowOnLast(
                    ae.Flatten().InnerExceptions.Select(LazyCreateError));
            }
            catch (Exception e)
            {
                ThrowTerminatingError(LazyCreateError(e));
            }
        }