Exemple #1
0
        public void Scenario1()
        {
            ApiStatus result;

            Principal principal;

            PrincipalSetup pSetup = new PrincipalSetup();

            pSetup.PrincipalType = PrincipalTypes.user;
            pSetup.Login         = "******";
            pSetup.Name          = "tst.sdk_tst";
            pSetup.Password      = "******";

            result = this.Api.PrincipalUpdate(pSetup, out principal);
            Assert.IsTrue(result.Code == StatusCodes.OK);

            MeetingDetail detailItem;
            var           meetingUpdateItem = new MeetingUpdateItem();

            meetingUpdateItem.Name            = "tst.SDK_debugging2";
            meetingUpdateItem.MeetingItemType = SCOtype.Meeting;
            meetingUpdateItem.FolderId        = "838570252";
            result = this.Api.MeetingCreate(meetingUpdateItem, out detailItem);
            Assert.IsTrue(result.Code == StatusCodes.OK);

            result = this.Api.ParticipantSubscribe(detailItem.ScoId, principal.PrincipalId);
            Assert.IsTrue(result.Code == StatusCodes.OK);

            WebClient client   = new WebClient();
            var       response = client.OpenRead(detailItem.FullUrl);

            response.Close();

            var reportResult = this.Api.Report_MeetingAttendance(detailItem.ScoId, string.Empty);
        }
Exemple #2
0
        public JsonResult UpdateUser(UserDTO user)
        {
            var provider = this.GetProvider();

            var meeting = this.CanvasCourseMeetingModel.GetOneByCourseId(Credentials.Id, Model.custom_canvas_course_id).Value;

            if (meeting == null)
            {
                return(this.Json(user));
            }

            if (user.ac_id == null || user.ac_id == "0")
            {
                var acUser = provider.GetAllByEmail(HttpUtility.UrlEncode(user.login_id ?? user.email));
                if (acUser.Values == null || acUser.Values.Count() == 0)
                {
                    var setup = new PrincipalSetup()
                    {
                        Email     = user.login_id ?? user.email,
                        FirstName = HttpUtility.UrlEncode(user.name),
                        LastName  = HttpUtility.UrlEncode(user.name),
                        Name      = HttpUtility.UrlEncode(user.name),
                        Password  = System.Web.Security.Membership.GeneratePassword(8, 2),
                        Login     = user.login_id ?? user.email
                    };
                    var pu = provider.PrincipalUpdate(setup);
                    if (pu.Principal != null)
                    {
                        user.ac_id = pu.Principal.PrincipalId;
                    }
                }
                else
                {
                    user.ac_id = acUser.Values.First().PrincipalId;
                }
            }

            if (user.ac_role == null)
            {
                provider.UpdateScoPermissionForPrincipal(meeting.ScoId, user.ac_id, MeetingPermissionId.remove);
                return(Json(user));
            }

            var permission = MeetingPermissionId.view;

            if (user.ac_role.ToLower() == "presenter")
            {
                permission = MeetingPermissionId.mini_host;
            }
            else if (user.ac_role.ToLower() == "host")
            {
                permission = MeetingPermissionId.host;
            }

            var res = provider.UpdateScoPermissionForPrincipal(meeting.ScoId, user.ac_id, permission);

            return(Json(user));
        }
Exemple #3
0
        private Principal CreatePrincipal(
            IAdobeConnectProxy provider,
            string login,
            string email,
            string firstName,
            string lastName,
            bool acUsesEmailAsLogin)
        {
            if (string.IsNullOrWhiteSpace(firstName))
            {
                throw new Core.WarningMessageException("Adobe Connect User's First Name can't be empty.");
            }
            if (string.IsNullOrWhiteSpace(lastName))
            {
                throw new Core.WarningMessageException("Adobe Connect User's Last Name can't be empty.");
            }

            var setup = new PrincipalSetup
            {
                Email     = string.IsNullOrWhiteSpace(email) ? null : email,
                FirstName = firstName,
                LastName  = lastName,
                Name      = login,
                Login     = login,
                Type      = PrincipalType.user,
            };

            PrincipalResult pu = provider.PrincipalUpdate(setup, false, false);

            if (!pu.Success)
            {
                if (pu.Status.InvalidField == "login" && pu.Status.SubCode == StatusSubCodes.duplicate)
                {
                    if (acUsesEmailAsLogin)
                    {
                        UserCollectionResult guestsByEmail = provider.ReportGuestsByEmail(HttpUtilsInternal.UrlEncode(email));
                        if (guestsByEmail.Success && guestsByEmail.Values.Any())
                        {
                            throw new Core.WarningMessageException(string.Format(Messages.PrincipalEmailUsedForGuest, email));
                        }
                    }
                    else
                    {
                        UserCollectionResult guestsByLogin = provider.ReportGuestsByLogin(login);
                        if (guestsByLogin.Success && guestsByLogin.Values.Any())
                        {
                            throw new Core.WarningMessageException(string.Format(Messages.PrincipalLoginUsedForGuest, login));
                        }
                    }
                }
            }

            if (pu.Principal != null)
            {
                return(pu.Principal);
            }
            return(null);
        }
Exemple #4
0
        /// <summary>
        /// Creates or updates a user or group. The user or group (that is, the principal) is created or
        /// updated in the same account as the user making the call.
        /// </summary>
        /// <param name="principalSetup">The principal setup.</param>
        /// <returns>Status Info.</returns>
        public PrincipalResult PrincipalUpdate(PrincipalSetup principalSetup, bool isUpdateOperation = false)
        {
            // action=principal-update
            var commandParams = QueryStringBuilder.EntityToQueryString(principalSetup, isUpdateOperation);

            StatusInfo status;
            var        doc = requestProcessor.Process(Commands.Principal.Update, commandParams, out status);

            return(new PrincipalResult(status, PrincipalParser.Parse(doc)));
        }
Exemple #5
0
        public void PrincipalUpdate()
        {
            PrincipalSetup pSetup = new PrincipalSetup();
            Principal      principal;

            ApiStatus result = this.Api.PrincipalUpdate(pSetup, out principal);

            Assert.AreEqual(StatusCodes.OK, result.Code);
            Assert.IsNotNull(principal);
        }
Exemple #6
0
        public void WillUpdatePassword()
        {
            var login            = "******";
            var email            = login;
            var password         = "******";
            var acApiUrl         = "https://connectstage.esynctraining.com/";
            var adobeConnectRoot = new Uri(acApiUrl);
            var con        = new ConnectionDetails(adobeConnectRoot);
            var acProvider = new AdobeConnectProvider(con);
            var proxy      = new AdobeConnectProxy(acProvider, new FakeLogger(), adobeConnectRoot, String.Empty);

            proxy.Login(new UserCredentials("*****@*****.**", "Welcome1"));//admin

            var _adobeConnectAccountService = new AdobeConnectAccountService(new FakeLogger());
            //proxy.PrincipalUpdatePassword()

            var existingPrincipalsResult = proxy.GetAllByEmail(email);

            if (!existingPrincipalsResult.Success)
            {
                return;
            }

            var existingPrincipal = existingPrincipalsResult.Values.FirstOrDefault();

            var principalSetup = new PrincipalSetup
            {
                PrincipalId = existingPrincipal?.PrincipalId,
                Email       = email,
                Login       = email,
                FirstName   = "aaa",
                LastName    = "bbb",
                SendEmail   = true,
                HasChildren = false,
                Type        = PrincipalType.user
            };
            var updatePrincipalResult = proxy.PrincipalUpdate(principalSetup, existingPrincipal != null);

            var updateResult = proxy.PrincipalUpdatePassword(existingPrincipal?.PrincipalId, password);

            var userProxy = _adobeConnectAccountService.GetProvider(new AdobeConnectAccess(new Uri(acApiUrl), email, password), true);
        }
Exemple #7
0
        private static Principal CreatePrincipal(PrincipalInputDto user, ILmsLicense credentials, IAdobeConnectProxy provider)
        {
            string login = (credentials.ACUsesEmailAsLogin ?? false) ? null : user.Login;

            var setup = new PrincipalSetup
            {
                Email       = user.Email,
                FirstName   = user.FirstName,
                LastName    = user.LastName,
                Login       = login,
                SendEmail   = user.SendEmail,
                HasChildren = false,
                Type        = PrincipalType.user,
                Password    = user.Password,
                //Name = NOTE: name is used for groups ONLY!!
            };

            PrincipalResult pu = provider.PrincipalUpdate(setup, false, false);

            if (!pu.Success)
            {
                if (pu.Status.InvalidField == "login" && pu.Status.SubCode == StatusSubCodes.duplicate)
                {
                    throw new WarningMessageException(string.Format(Messages.PrincipalValidateAlreadyInAc, login ?? user.Email));
                }

                if (pu.Status.InvalidField == "name" && pu.Status.SubCode == StatusSubCodes.range)
                {
                    throw new WarningMessageException(Messages.PrincipalValidateNameLength);
                }

                if (pu.Status.InvalidField == "email" && pu.Status.SubCode == StatusSubCodes.range)
                {
                    throw new WarningMessageException(Messages.PrincipalValidateEmailLength);
                }

                if (pu.Status.InvalidField == "email" && pu.Status.SubCode == StatusSubCodes.format)
                {
                    throw new WarningMessageException(Messages.PrincipalValidateEmailFormat);
                }

                if (pu.Status.InvalidField == "login" && pu.Status.SubCode == StatusSubCodes.range)
                {
                    throw new WarningMessageException(Messages.PrincipalValidateLoginLength);
                }

                string additionalData = string.Format("firstName: {0}, lastName: {1}, login: {2}, email: {3}", user.FirstName, user.LastName, user.Login, user.Email);
                if (pu.Status.UnderlyingExceptionInfo != null)
                {
                    throw new InvalidOperationException(string.Format("AC.PrincipalUpdate error. Additional Data: {0}", additionalData), pu.Status.UnderlyingExceptionInfo);
                }

                if (!string.IsNullOrEmpty(pu.Status.InvalidField))
                {
                    throw new InvalidOperationException(string.Format("AC.PrincipalUpdate error. Invalid Field: {0}. Status.SubCode: {1}. Additional Data: {2}", pu.Status.InvalidField, pu.Status.SubCode, additionalData));
                }

                throw new InvalidOperationException(string.Format("AC.PrincipalUpdate error. Status.Code: {0}. Status.SubCode: {1}. Additional Data: {2}", pu.Status.Code, pu.Status.SubCode, additionalData));
            }

            Principal createdPrincipal = pu.Principal;

            return(createdPrincipal);
        }
Exemple #8
0
        /// <summary>
        /// Creates or updates a user or group. The user or group (that is, the principal) is created or
        /// updated in the same account as the user making the call.
        /// </summary>
        /// <param name="adobeConnectXmlApi">The adobe connect XML API.</param>
        /// <param name="principalSetup"><see cref="PrincipalSetup" /></param>
        /// <param name="principal"><see cref="Principal" /></param>
        /// <returns>
        ///   <see cref="ApiStatus" />
        /// </returns>
        public static ApiStatus PrincipalUpdate(this AdobeConnectXmlAPI adobeConnectXmlApi, PrincipalSetup principalSetup, out Principal principal)
        {
            string cmdParams = Helpers.StructToQueryString(principalSetup, true);

            principal = null;

            ApiStatus s = adobeConnectXmlApi.ProcessApiRequest("principal-update", cmdParams);

            if (s.Code != StatusCodes.OK || s.ResultDocument == null)
            {
                return(s);
            }

            principal = XmlSerializerHelpersGeneric.FromXML <Principal>(s.ResultDocument.XPathSelectElement("//principal").CreateReader());

            return(s);
        }