示例#1
0
        public RmResource FindById(string id, AttributesToFetch attributes = null)
        {
            Initialize();

            attributes = attributes ?? AttributesToFetch.All;

            var ctx = LogContext.WithConfigFormat();

            _log.Debug(ctx.Format("Finding object by id {0} with attributes {1}"), id, attributes.GetNames().ToJSON());

            RmResource resource = null;

            try
            {
                var reference = new RmReference(id);

                if (attributes != AttributesToFetch.All)
                {
                    attributes = attributes.AppendAttribute(RmResource.AttributeNames.ObjectType.Name);
                }

                resource = _defaultClient.Get(reference, attributes.GetNames());

                _log.Debug(ctx.Format("Found object with id {0}, type {1}"), id, resource.ObjectType);
            }
            catch
            {
                // catching exc - meaning that object not found

                _log.Warn(ctx.Format("Object with id {0} not found"), id);
            }
            return(resource);
        }
示例#2
0
        protected override void InitializeAuthenticationGate(IServiceProvider provider)
        {
            sentSMS = false;

            // When the activity is first loaded, we're going to try to retrieve the user info from the registration data
            if (this.AuthenticationGateActivity.RegistrationData == null ||
                string.IsNullOrEmpty(this.userCellPhone = UnicodeEncoding.Unicode.GetString(this.AuthenticationGateActivity.RegistrationData)))
            {
                //Looks like our cell phone data was not stored in registration data
                //Default to FIM store
                using (ServiceSecurityContext.Current.WindowsIdentity.Impersonate())
                {
                    using (DefaultClient client = new DefaultClient())
                    {
                        client.RefreshSchema();

                        SequentialWorkflow containingSequentialWorkflow = null;
                        SequentialWorkflow.TryGetContainingWorkflow(this.AuthenticationGateActivity, out containingSequentialWorkflow);

                        Guid targetUser;
                        if (containingSequentialWorkflow.ActorId == CellOTPGate.AnonymousID)
                        {
                            targetUser = containingSequentialWorkflow.TargetId;
                        }
                        else
                        {
                            targetUser = containingSequentialWorkflow.ActorId;
                        }

                        RmPerson person = client.Get(new Microsoft.ResourceManagement.ObjectModel.RmReference(targetUser.ToString())) as RmPerson;
                        this.userCellPhone = person.MobilePhone;
                    }
                }
            }

            base.InitializeAuthenticationGate(provider);
        }