public ADProviderCommonParameters()
 {
     this._formatType = ADProviderDefaults.PathFormat;
     this._server     = ADProviderDefaults.Server;
     this._isGC       = ADProviderDefaults.IsGC;
     this._authType   = ADProviderDefaults.AuthType;
 }
Example #2
0
        public static bool IsChildPath(string path, string parentPath, bool includeSelf, ADPathFormat format)
        {
            if (string.IsNullOrEmpty(path) || string.IsNullOrEmpty(parentPath))
            {
                if (!includeSelf)
                {
                    return(false);
                }
                else
                {
                    return(path == parentPath);
                }
            }
            else
            {
                ADPathFormat aDPathFormat = format;
                switch (aDPathFormat)
                {
                case ADPathFormat.X500:
                {
                    return(X500Path.IsChildPath(path, parentPath, includeSelf));
                }

                case ADPathFormat.Canonical:
                {
                    return(CanonicalPath.IsChildPath(path, parentPath, includeSelf));
                }
                }
                return(false);
            }
        }
		public ADProviderCommonParameters()
		{
			this._formatType = ADProviderDefaults.PathFormat;
			this._server = ADProviderDefaults.Server;
			this._isGC = ADProviderDefaults.IsGC;
			this._authType = ADProviderDefaults.AuthType;
		}
Example #4
0
 public ADDriveInfo() : base(null)
 {
     this._formatType = ADProviderDefaults.PathFormat;
     this._authType   = ADProviderDefaults.AuthType;
     this._isGC       = ADProviderDefaults.IsGC;
     this._ssl        = ADProviderDefaults.Ssl;
     this._encryption = ADProviderDefaults.Encryption;
     this._signing    = ADProviderDefaults.Signing;
 }
Example #5
0
 public ADDriveInfo(string name, ProviderInfo provider, string root, string rootWithAbsoluteToken, string description, PSCredential credential) : base(name, provider, rootWithAbsoluteToken, description, credential)
 {
     this._formatType = ADProviderDefaults.PathFormat;
     this._authType   = ADProviderDefaults.AuthType;
     this._isGC       = ADProviderDefaults.IsGC;
     this._ssl        = ADProviderDefaults.Ssl;
     this._encryption = ADProviderDefaults.Encryption;
     this._signing    = ADProviderDefaults.Signing;
     this._rootWithoutAbsolutePathToken = root;
 }
Example #6
0
		static ADProviderDefaults()
		{
			ADProviderDefaults.PathFormat = ADPathFormat.X500;
			ADProviderDefaults.HostType = ADPathHostType.Server;
			ADProviderDefaults.Server = null;
			ADProviderDefaults.IsGC = false;
			ADProviderDefaults.AuthType = ADAuthType.Negotiate;
			ADProviderDefaults.Ssl = false;
			ADProviderDefaults.Encryption = true;
			ADProviderDefaults.Signing = true;
			ADProviderDefaults.ServerSearchSizeLimit = 0;
			ADProviderDefaults.ServerSearchPageSize = 0x100;
			ADProviderDefaults.SearchFilter = "(objectclass=*)";
			ADProviderDefaults.InternalProviderSearchPageSize = 0x100;
		}
Example #7
0
 static ADProviderDefaults()
 {
     ADProviderDefaults.PathFormat                     = ADPathFormat.X500;
     ADProviderDefaults.HostType                       = ADPathHostType.Server;
     ADProviderDefaults.Server                         = null;
     ADProviderDefaults.IsGC                           = false;
     ADProviderDefaults.AuthType                       = ADAuthType.Negotiate;
     ADProviderDefaults.Ssl                            = false;
     ADProviderDefaults.Encryption                     = true;
     ADProviderDefaults.Signing                        = true;
     ADProviderDefaults.ServerSearchSizeLimit          = 0;
     ADProviderDefaults.ServerSearchPageSize           = 0x100;
     ADProviderDefaults.SearchFilter                   = "(objectclass=*)";
     ADProviderDefaults.InternalProviderSearchPageSize = 0x100;
 }
Example #8
0
		public static string ConvertPath(ADSessionInfo sessionInfo, string path, ADPathFormat fromFormat, ADPathFormat toFormat)
		{
			string str;
			if (fromFormat != toFormat)
			{
				if (fromFormat == ADPathFormat.Canonical && !string.IsNullOrEmpty(path) && CanonicalPath.IndexOfFirstDelimiter(path) == -1)
				{
					path = string.Concat(path, "/");
				}
				using (ADAccountManagement aDAccountManagement = new ADAccountManagement(sessionInfo))
				{
					str = aDAccountManagement.TranslateName(path, fromFormat, toFormat);
				}
				return str;
			}
			else
			{
				return path;
			}
		}
Example #9
0
        public static string ConvertPath(ADSessionInfo sessionInfo, string path, ADPathFormat fromFormat, ADPathFormat toFormat)
        {
            string str;

            if (fromFormat != toFormat)
            {
                if (fromFormat == ADPathFormat.Canonical && !string.IsNullOrEmpty(path) && CanonicalPath.IndexOfFirstDelimiter(path) == -1)
                {
                    path = string.Concat(path, "/");
                }
                using (ADAccountManagement aDAccountManagement = new ADAccountManagement(sessionInfo))
                {
                    str = aDAccountManagement.TranslateName(path, fromFormat, toFormat);
                }
                return(str);
            }
            else
            {
                return(path);
            }
        }
Example #10
0
        private ActiveDirectoryNameFormat GetNameFormat(ADPathFormat pathFormat)
        {
            ActiveDirectoryNameFormat activeDirectoryNameFormat = ActiveDirectoryNameFormat.DistinguishedName;
            ADPathFormat aDPathFormat = pathFormat;

            switch (aDPathFormat)
            {
            case ADPathFormat.X500:
            {
                activeDirectoryNameFormat = ActiveDirectoryNameFormat.DistinguishedName;
                break;
            }

            case ADPathFormat.Canonical:
            {
                activeDirectoryNameFormat = ActiveDirectoryNameFormat.CanonicalName;
                break;
            }
            }
            return(activeDirectoryNameFormat);
        }
Example #11
0
        public static string MakePath(string parent, string child, ADPathFormat format)
        {
            if (!string.IsNullOrEmpty(parent) || !string.IsNullOrEmpty(child))
            {
                if (!string.IsNullOrEmpty(parent))
                {
                    if (!string.IsNullOrEmpty(child))
                    {
                        ADPathFormat aDPathFormat = format;
                        switch (aDPathFormat)
                        {
                        case ADPathFormat.X500:
                        {
                            return(X500Path.MakePath(parent, child));
                        }

                        case ADPathFormat.Canonical:
                        {
                            return(CanonicalPath.MakePath(parent, child));
                        }
                        }
                        return(null);
                    }
                    else
                    {
                        return(parent);
                    }
                }
                else
                {
                    return(child);
                }
            }
            else
            {
                return("");
            }
        }
Example #12
0
		public static bool ComparePath(string path1, string path2, ADPathFormat format)
		{
			if (string.IsNullOrEmpty(path1) || string.IsNullOrEmpty(path2))
			{
				return path1 == path2;
			}
			else
			{
				ADPathFormat aDPathFormat = format;
				switch (aDPathFormat)
				{
					case ADPathFormat.X500:
					{
						return X500Path.ComparePath(path1, path2);
					}
					case ADPathFormat.Canonical:
					{
						return CanonicalPath.ComparePath(path1, path2);
					}
				}
				return false;
			}
		}
Example #13
0
		public static string GetParentPath(string path, string root, ADPathFormat format)
		{
			if (!string.IsNullOrEmpty(path))
			{
				ADPathFormat aDPathFormat = format;
				switch (aDPathFormat)
				{
					case ADPathFormat.X500:
					{
						return X500Path.GetParentPath(path, root);
					}
					case ADPathFormat.Canonical:
					{
						return CanonicalPath.GetParentPath(path, root);
					}
				}
				return null;
			}
			else
			{
				return "";
			}
		}
Example #14
0
        public static string GetParentPath(string path, string root, ADPathFormat format)
        {
            if (!string.IsNullOrEmpty(path))
            {
                ADPathFormat aDPathFormat = format;
                switch (aDPathFormat)
                {
                case ADPathFormat.X500:
                {
                    return(X500Path.GetParentPath(path, root));
                }

                case ADPathFormat.Canonical:
                {
                    return(CanonicalPath.GetParentPath(path, root));
                }
                }
                return(null);
            }
            else
            {
                return("");
            }
        }
Example #15
0
        public static bool ComparePath(string path1, string path2, ADPathFormat format)
        {
            if (string.IsNullOrEmpty(path1) || string.IsNullOrEmpty(path2))
            {
                return(path1 == path2);
            }
            else
            {
                ADPathFormat aDPathFormat = format;
                switch (aDPathFormat)
                {
                case ADPathFormat.X500:
                {
                    return(X500Path.ComparePath(path1, path2));
                }

                case ADPathFormat.Canonical:
                {
                    return(CanonicalPath.ComparePath(path1, path2));
                }
                }
                return(false);
            }
        }
Example #16
0
        internal string TranslateName(string name, ADPathFormat formatOffered, ADPathFormat formatDesired)
        {
            this.Init();
            TranslateNameRequest translateNameRequest = new TranslateNameRequest();

            translateNameRequest.Names         = new string[1];
            translateNameRequest.Names[0]      = name;
            translateNameRequest.FormatOffered = this.GetNameFormat(formatOffered);
            translateNameRequest.FormatDesired = this.GetNameFormat(formatDesired);
            TranslateNameResponse translateNameResponse = this._acctMgmt.TranslateName(this._sessionHandle, translateNameRequest);

            ActiveDirectoryNameTranslateResult[] nameTranslateResult = translateNameResponse.NameTranslateResult;
            if (nameTranslateResult[0].Result != 0)
            {
                object[] objArray = new object[1];
                objArray[0] = name;
                throw ExceptionHelper.GetExceptionFromErrorCode(Convert.ToInt32(nameTranslateResult[0].Result), string.Format(CultureInfo.CurrentCulture, StringResources.TranslateNameError, objArray), null);
            }
            else
            {
                string str = nameTranslateResult[0].Name;
                return(str);
            }
        }
Example #17
0
        public static bool IsValidPath(string path, ADPathFormat format)
        {
            if (!string.IsNullOrEmpty(path))
            {
                ADPathFormat aDPathFormat = format;
                switch (aDPathFormat)
                {
                case ADPathFormat.X500:
                {
                    return(X500Path.IsValidPath(path));
                }

                case ADPathFormat.Canonical:
                {
                    return(CanonicalPath.IsValidPath(path));
                }
                }
                return(false);
            }
            else
            {
                return(true);
            }
        }
Example #18
0
		public ADDriveInfo(string name, ProviderInfo provider, string root, string rootWithAbsoluteToken, string description, PSCredential credential) : base(name, provider, rootWithAbsoluteToken, description, credential)
		{
			this._formatType = ADProviderDefaults.PathFormat;
			this._authType = ADProviderDefaults.AuthType;
			this._isGC = ADProviderDefaults.IsGC;
			this._ssl = ADProviderDefaults.Ssl;
			this._encryption = ADProviderDefaults.Encryption;
			this._signing = ADProviderDefaults.Signing;
			this._rootWithoutAbsolutePathToken = root;
		}
Example #19
0
		public ADDriveInfo() : base(null)
		{
			this._formatType = ADProviderDefaults.PathFormat;
			this._authType = ADProviderDefaults.AuthType;
			this._isGC = ADProviderDefaults.IsGC;
			this._ssl = ADProviderDefaults.Ssl;
			this._encryption = ADProviderDefaults.Encryption;
			this._signing = ADProviderDefaults.Signing;
		}
Example #20
0
		internal string TranslateName(string name, ADPathFormat formatOffered, ADPathFormat formatDesired)
		{
			this.Init();
			TranslateNameRequest translateNameRequest = new TranslateNameRequest();
			translateNameRequest.Names = new string[1];
			translateNameRequest.Names[0] = name;
			translateNameRequest.FormatOffered = this.GetNameFormat(formatOffered);
			translateNameRequest.FormatDesired = this.GetNameFormat(formatDesired);
			TranslateNameResponse translateNameResponse = this._acctMgmt.TranslateName(this._sessionHandle, translateNameRequest);
			ActiveDirectoryNameTranslateResult[] nameTranslateResult = translateNameResponse.NameTranslateResult;
			if (nameTranslateResult[0].Result != 0)
			{
				object[] objArray = new object[1];
				objArray[0] = name;
				throw ExceptionHelper.GetExceptionFromErrorCode(Convert.ToInt32 (nameTranslateResult[0].Result), string.Format(CultureInfo.CurrentCulture, StringResources.TranslateNameError, objArray), null);
			}
			else
			{
				string str = nameTranslateResult[0].Name;
				return str;
			}
		}
Example #21
0
		private ActiveDirectoryNameFormat GetNameFormat(ADPathFormat pathFormat)
		{
			ActiveDirectoryNameFormat activeDirectoryNameFormat = ActiveDirectoryNameFormat.DistinguishedName;
			ADPathFormat aDPathFormat = pathFormat;
			switch (aDPathFormat)
			{
				case ADPathFormat.X500:
				{
					activeDirectoryNameFormat = ActiveDirectoryNameFormat.DistinguishedName;
					break;
				}
				case ADPathFormat.Canonical:
				{
					activeDirectoryNameFormat = ActiveDirectoryNameFormat.CanonicalName;
					break;
				}
			}
			return activeDirectoryNameFormat;
		}
Example #22
0
		private ADObject GetValidatedADObject(ADSessionInfo sessionInfo, string path, Collection<string> propertiesToRetrieve, ADPathFormat formatType)
		{
			ADObject aDObject;
			this.Trace(DebugLogLevel.Verbose, "Entering GetValidatedADObject");
			this.Trace(DebugLogLevel.Info, string.Format("GetValidatedADObject: path = {0}", path));
			ADObjectSearcher aDObjectSearcher = this.BuildADObjectSearcher(sessionInfo);
			using (aDObjectSearcher)
			{
				aDObjectSearcher.SearchRoot = path;
				aDObjectSearcher.Scope = ADSearchScope.Base;
				if (propertiesToRetrieve != null)
				{
					aDObjectSearcher.Properties.AddRange(propertiesToRetrieve);
				}
				if (formatType == ADPathFormat.Canonical)
				{
					aDObjectSearcher.Properties.Add("canonicalName");
				}
				aDObject = aDObjectSearcher.FindOne();
			}
			this.Trace(DebugLogLevel.Verbose, "Leaving GetValidatedADObject");
			return aDObject;
		}
Example #23
0
		public static string MakePath(string parent, string child, ADPathFormat format)
		{
			if (!string.IsNullOrEmpty(parent) || !string.IsNullOrEmpty(child))
			{
				if (!string.IsNullOrEmpty(parent))
				{
					if (!string.IsNullOrEmpty(child))
					{
						ADPathFormat aDPathFormat = format;
						switch (aDPathFormat)
						{
							case ADPathFormat.X500:
							{
								return X500Path.MakePath(parent, child);
							}
							case ADPathFormat.Canonical:
							{
								return CanonicalPath.MakePath(parent, child);
							}
						}
						return null;
					}
					else
					{
						return parent;
					}
				}
				else
				{
					return child;
				}
			}
			else
			{
				return "";
			}
		}
Example #24
0
		public static bool IsChildPath(string path, string parentPath, bool includeSelf, ADPathFormat format)
		{
			if (string.IsNullOrEmpty(path) || string.IsNullOrEmpty(parentPath))
			{
				if (!includeSelf)
				{
					return false;
				}
				else
				{
					return path == parentPath;
				}
			}
			else
			{
				ADPathFormat aDPathFormat = format;
				switch (aDPathFormat)
				{
					case ADPathFormat.X500:
					{
						return X500Path.IsChildPath(path, parentPath, includeSelf);
					}
					case ADPathFormat.Canonical:
					{
						return CanonicalPath.IsChildPath(path, parentPath, includeSelf);
					}
				}
				return false;
			}
		}
Example #25
0
		public static bool IsValidPath(string path, ADPathFormat format)
		{
			if (!string.IsNullOrEmpty(path))
			{
				ADPathFormat aDPathFormat = format;
				switch (aDPathFormat)
				{
					case ADPathFormat.X500:
					{
						return X500Path.IsValidPath(path);
					}
					case ADPathFormat.Canonical:
					{
						return CanonicalPath.IsValidPath(path);
					}
				}
				return false;
			}
			else
			{
				return true;
			}
		}