Ejemplo n.º 1
0
        internal static PropertyValueBaseXML Create(ProviderPropertyDefinition pdef, object value)
        {
            ADPropertyDefinition adpropertyDefinition = pdef as ADPropertyDefinition;
            IFormatProvider      formatProvider       = (adpropertyDefinition != null) ? adpropertyDefinition.FormatProvider : null;
            ADObjectId           adobjectId           = value as ADObjectId;

            if (adobjectId != null)
            {
                return(ADObjectIdXML.Serialize(adobjectId));
            }
            OrganizationId organizationId = value as OrganizationId;

            if (organizationId != null)
            {
                return(OrganizationIdXML.Serialize(organizationId));
            }
            RawSecurityDescriptor rawSecurityDescriptor = value as RawSecurityDescriptor;

            if (rawSecurityDescriptor != null)
            {
                return(new PropertyStringValueXML
                {
                    StrValue = CommonUtils.GetSDDLString(rawSecurityDescriptor)
                });
            }
            Exception ex;

            if (pdef.IsBinary)
            {
                byte[] binValue;
                if (ADValueConvertor.TryConvertValueToBinary(value, formatProvider, out binValue, out ex))
                {
                    return(new PropertyBinaryValueXML
                    {
                        BinValue = binValue
                    });
                }
                MrsTracer.Common.Warning("Failed to convert {0} to binary, will try string: {1}", new object[]
                {
                    pdef.Name,
                    CommonUtils.FullExceptionMessage(ex)
                });
            }
            PropertyStringValueXML propertyStringValueXML = new PropertyStringValueXML();
            string text;

            if (!ADValueConvertor.TryConvertValueToString(value, formatProvider, out text, out ex))
            {
                text = value.ToString();
                MrsTracer.Common.Warning("Failed to convert {0} to string, defaulting to '{1}': {2}", new object[]
                {
                    pdef.Name,
                    text,
                    CommonUtils.FullExceptionMessage(ex)
                });
            }
            propertyStringValueXML.StrValue = text;
            return(propertyStringValueXML);
        }
Ejemplo n.º 2
0
 internal static OrganizationIdXML Serialize(OrganizationId id)
 {
     if (id == null)
     {
         return(null);
     }
     return(new OrganizationIdXML
     {
         OrganizationalUnit = ADObjectIdXML.Serialize(id.OrganizationalUnit),
         ConfigurationUnit = ADObjectIdXML.Serialize(id.ConfigurationUnit)
     });
 }
Ejemplo n.º 3
0
 internal MoveHistoryEntryInternal(RequestJobBase requestJob, ReportData report)
 {
     this.hasReadCompressedEntries = false;
     this.Status                     = (int)requestJob.Status;
     this.Flags                      = (int)requestJob.Flags;
     this.SourceDatabase             = ADObjectIdXML.Serialize(requestJob.SourceDatabase);
     this.SourceVersion              = requestJob.SourceVersion;
     this.SourceServer               = requestJob.SourceServer;
     this.SourceArchiveDatabase      = ADObjectIdXML.Serialize(requestJob.SourceArchiveDatabase);
     this.SourceArchiveVersion       = requestJob.SourceArchiveVersion;
     this.SourceArchiveServer        = requestJob.SourceArchiveServer;
     this.DestinationDatabase        = ADObjectIdXML.Serialize(requestJob.TargetDatabase);
     this.DestinationVersion         = requestJob.TargetVersion;
     this.DestinationServer          = requestJob.TargetServer;
     this.DestinationArchiveDatabase = ADObjectIdXML.Serialize(requestJob.TargetArchiveDatabase);
     this.DestinationArchiveVersion  = requestJob.TargetArchiveVersion;
     this.DestinationArchiveServer   = requestJob.TargetArchiveServer;
     this.RemoteHostName             = requestJob.RemoteHostName;
     if (requestJob.RemoteCredential == null)
     {
         this.RemoteCredentialUserName = null;
     }
     else if (requestJob.RemoteCredential.Domain == null)
     {
         this.RemoteCredentialUserName = requestJob.RemoteCredential.UserName;
     }
     else
     {
         this.RemoteCredentialUserName = requestJob.RemoteCredential.Domain + "\\" + requestJob.RemoteCredential.UserName;
     }
     this.RemoteDatabaseName        = requestJob.RemoteDatabaseName;
     this.RemoteArchiveDatabaseName = requestJob.RemoteArchiveDatabaseName;
     this.BadItemLimit            = requestJob.BadItemLimit;
     this.BadItemsEncountered     = requestJob.BadItemsEncountered;
     this.LargeItemLimit          = requestJob.LargeItemLimit;
     this.LargeItemsEncountered   = requestJob.LargeItemsEncountered;
     this.MissingItemsEncountered = requestJob.MissingItemsEncountered;
     this.TimeTracker             = requestJob.TimeTracker;
     this.MRSServerName           = requestJob.MRSServerName;
     this.TotalMailboxSize        = requestJob.TotalMailboxSize;
     this.TotalMailboxItemCount   = requestJob.TotalMailboxItemCount;
     this.TotalArchiveSize        = requestJob.TotalArchiveSize;
     this.TotalArchiveItemCount   = requestJob.TotalArchiveItemCount;
     this.TargetDeliveryDomain    = requestJob.TargetDeliveryDomain;
     this.ArchiveDomain           = requestJob.ArchiveDomain;
     this.FailureCode             = requestJob.FailureCode;
     this.FailureType             = requestJob.FailureType;
     this.MessageData             = CommonUtils.ByteSerialize(requestJob.Message);
     this.report = report;
 }