Example #1
0
        /// <summary>
        /// Display version for SharePoint
        /// </summary>
        /// <param name="version">SharePoint version</param>
        /// <returns>SharePoint version in string format</returns>
        public static string DisplaySharePointVersion(this SPVersion version)
        {
            switch (version)
            {
            case SPVersion.SP2010:
                return("2010");

            case SPVersion.SP2013:
            case SPVersion.SP2013Legacy:
                return("2013");

            case SPVersion.SP2016:
            case SPVersion.SP2016Legacy:
                return("2016");

            case SPVersion.SP2019:
                return("2019");

            case SPVersion.SPO:
                return("Online");

            default:
                return(string.Empty);
            }
        }
Example #2
0
        private static SPVersion NormalizeSharePointVersions(SPVersion spVersion)
        {
            if (spVersion == SPVersion.SP2013Legacy)
            {
                spVersion = SPVersion.SP2013;
            }
            if (spVersion == SPVersion.SP2016Legacy)
            {
                spVersion = SPVersion.SP2016;
            }

            return(spVersion);
        }
Example #3
0
        /// <summary>
        /// User Transformator constructor
        /// </summary>
        /// <param name="baseTransformationInformation">Transformation configuration settings</param>
        /// <param name="sourceContext">Source Context</param>
        /// <param name="targetContext">Target Context</param>
        /// <param name="logObservers">Connected loggers</param>
        public UserTransformator(BaseTransformationInformation baseTransformationInformation, ClientContext sourceContext, ClientContext targetContext, IList <ILogObserver> logObservers = null)
        {
            // Hookup logging
            if (logObservers != null)
            {
                foreach (var observer in logObservers)
                {
                    base.RegisterObserver(observer);
                }
            }

            // Ensure source and target context are set
            if (sourceContext == null && targetContext != null)
            {
                sourceContext = targetContext;
            }

            if (targetContext == null && sourceContext != null)
            {
                targetContext = sourceContext;
            }

            this._sourceContext = sourceContext;
            this._targetContext = targetContext;

            // Load the User mapping file
            if (!string.IsNullOrEmpty(baseTransformationInformation?.UserMappingFile))
            {
                this._userMapping = CacheManager.Instance.GetUserMapping(baseTransformationInformation.UserMappingFile, logObservers);
            }
            else
            {
                this._userMapping = default; //Pass through if there is no mapping
            }

            if (!string.IsNullOrEmpty(baseTransformationInformation.LDAPConnectionString))
            {
                _ldapSpecifiedByUser = baseTransformationInformation?.LDAPConnectionString;
            }
            else
            {
                _ldapSpecifiedByUser = default;
            }

            _sourceVersion   = baseTransformationInformation?.SourceVersion ?? SPVersion.SPO; // SPO Fall Back
            _skipUserMapping = baseTransformationInformation.SkipUserMapping;
        }
        /// <summary>
        /// Constructor for the asset transfer class
        /// </summary>
        /// <param name="source">Source connection to SharePoint</param>
        /// <param name="target">Target connection to SharePoint</param>
        public AssetTransfer(ClientContext source, ClientContext target, IList <ILogObserver> logObservers = null)
        {
            if (logObservers != null)
            {
                foreach (var observer in logObservers)
                {
                    base.RegisterObserver(observer);
                }
            }

            _sourceClientContext = source;
            _targetClientContext = target;

            // Check if we're calling asset transfer when source and target are the same
            var sourceUrl = _sourceClientContext?.Web.GetUrl();
            var targetUrl = _targetClientContext?.Web.GetUrl();

            inSameSite = sourceUrl.Equals(targetUrl, StringComparison.InvariantCultureIgnoreCase);
            _sourceContextSPVersion = GetVersion(_sourceClientContext);

            Validate(); // Perform validation
        }