internal static string ExpandWellKnownDN(DirectoryContext context, WellKnownDN dn)
        {
            switch (dn)
            {
            case WellKnownDN.RootDSE:
                return("RootDSE");

            case WellKnownDN.DefaultNamingContext:
            {
                using (DirectoryEntry entry2 = GetDirectoryEntry(context, "RootDSE"))
                {
                    return((string)PropertyManager.GetPropertyValue(context, entry2, PropertyManager.DefaultNamingContext));
                }
            }

            case WellKnownDN.SchemaNamingContext:
            {
                using (DirectoryEntry entry3 = GetDirectoryEntry(context, "RootDSE"))
                {
                    return((string)PropertyManager.GetPropertyValue(context, entry3, PropertyManager.SchemaNamingContext));
                }
            }

            case WellKnownDN.ConfigurationNamingContext:
            {
                using (DirectoryEntry entry4 = GetDirectoryEntry(context, "RootDSE"))
                {
                    return((string)PropertyManager.GetPropertyValue(context, entry4, PropertyManager.ConfigurationNamingContext));
                }
            }

            case WellKnownDN.PartitionsContainer:
                return("CN=Partitions," + ExpandWellKnownDN(context, WellKnownDN.ConfigurationNamingContext));

            case WellKnownDN.SitesContainer:
                return("CN=Sites," + ExpandWellKnownDN(context, WellKnownDN.ConfigurationNamingContext));

            case WellKnownDN.SystemContainer:
                return("CN=System," + ExpandWellKnownDN(context, WellKnownDN.DefaultNamingContext));

            case WellKnownDN.RidManager:
                return("CN=RID Manager$," + ExpandWellKnownDN(context, WellKnownDN.SystemContainer));

            case WellKnownDN.Infrastructure:
                return("CN=Infrastructure," + ExpandWellKnownDN(context, WellKnownDN.DefaultNamingContext));

            case WellKnownDN.RootDomainNamingContext:
            {
                using (DirectoryEntry entry = GetDirectoryEntry(context, "RootDSE"))
                {
                    return((string)PropertyManager.GetPropertyValue(context, entry, PropertyManager.RootDomainNamingContext));
                }
            }
            }
            throw new InvalidEnumArgumentException("dn", (int)dn, typeof(WellKnownDN));
        }
Esempio n. 2
0
        internal string ExpandWellKnownDN(WellKnownDN dn)
        {
            string      propertyValue = null;
            WellKnownDN wellKnownDN   = dn;

            if (wellKnownDN == WellKnownDN.RootDSE)
            {
                propertyValue = "RootDSE";
            }
            else if (wellKnownDN == WellKnownDN.DefaultNamingContext)
            {
                DirectoryEntry cachedDirectoryEntry = this.GetCachedDirectoryEntry("RootDSE");
                propertyValue = (string)PropertyManager.GetPropertyValue(this.context, cachedDirectoryEntry, PropertyManager.DefaultNamingContext);
            }
            else if (wellKnownDN == WellKnownDN.SchemaNamingContext)
            {
                DirectoryEntry directoryEntry = this.GetCachedDirectoryEntry("RootDSE");
                propertyValue = (string)PropertyManager.GetPropertyValue(this.context, directoryEntry, PropertyManager.SchemaNamingContext);
            }
            else if (wellKnownDN == WellKnownDN.ConfigurationNamingContext)
            {
                DirectoryEntry cachedDirectoryEntry1 = this.GetCachedDirectoryEntry("RootDSE");
                propertyValue = (string)PropertyManager.GetPropertyValue(this.context, cachedDirectoryEntry1, PropertyManager.ConfigurationNamingContext);
            }
            else if (wellKnownDN == WellKnownDN.PartitionsContainer)
            {
                propertyValue = string.Concat("CN=Partitions,", this.ExpandWellKnownDN(WellKnownDN.ConfigurationNamingContext));
            }
            else if (wellKnownDN == WellKnownDN.SitesContainer)
            {
                propertyValue = string.Concat("CN=Sites,", this.ExpandWellKnownDN(WellKnownDN.ConfigurationNamingContext));
            }
            else if (wellKnownDN == WellKnownDN.SystemContainer)
            {
                propertyValue = string.Concat("CN=System,", this.ExpandWellKnownDN(WellKnownDN.DefaultNamingContext));
            }
            else if (wellKnownDN == WellKnownDN.RidManager)
            {
                propertyValue = string.Concat("CN=RID Manager$,", this.ExpandWellKnownDN(WellKnownDN.SystemContainer));
            }
            else if (wellKnownDN == WellKnownDN.Infrastructure)
            {
                propertyValue = string.Concat("CN=Infrastructure,", this.ExpandWellKnownDN(WellKnownDN.DefaultNamingContext));
            }
            else if (wellKnownDN == WellKnownDN.RootDomainNamingContext)
            {
                DirectoryEntry directoryEntry1 = this.GetCachedDirectoryEntry("RootDSE");
                propertyValue = (string)PropertyManager.GetPropertyValue(this.context, directoryEntry1, PropertyManager.RootDomainNamingContext);
            }
            else
            {
                throw new InvalidEnumArgumentException("dn", (int)dn, typeof(WellKnownDN));
            }
            return(propertyValue);
        }
Esempio n. 3
0
		internal string ExpandWellKnownDN(WellKnownDN dn)
		{
			string propertyValue = null;
			WellKnownDN wellKnownDN = dn;
			if (wellKnownDN == WellKnownDN.RootDSE)
			{
				propertyValue = "RootDSE";
			}
			else if (wellKnownDN == WellKnownDN.DefaultNamingContext)
			{
				DirectoryEntry cachedDirectoryEntry = this.GetCachedDirectoryEntry("RootDSE");
				propertyValue = (string)PropertyManager.GetPropertyValue(this.context, cachedDirectoryEntry, PropertyManager.DefaultNamingContext);
			}
			else if (wellKnownDN == WellKnownDN.SchemaNamingContext)
			{
				DirectoryEntry directoryEntry = this.GetCachedDirectoryEntry("RootDSE");
				propertyValue = (string)PropertyManager.GetPropertyValue(this.context, directoryEntry, PropertyManager.SchemaNamingContext);
			}
			else if (wellKnownDN == WellKnownDN.ConfigurationNamingContext)
			{
				DirectoryEntry cachedDirectoryEntry1 = this.GetCachedDirectoryEntry("RootDSE");
				propertyValue = (string)PropertyManager.GetPropertyValue(this.context, cachedDirectoryEntry1, PropertyManager.ConfigurationNamingContext);
			}
			else if (wellKnownDN == WellKnownDN.PartitionsContainer)
			{
				propertyValue = string.Concat("CN=Partitions,", this.ExpandWellKnownDN(WellKnownDN.ConfigurationNamingContext));
			}
			else if (wellKnownDN == WellKnownDN.SitesContainer)
			{
				propertyValue = string.Concat("CN=Sites,", this.ExpandWellKnownDN(WellKnownDN.ConfigurationNamingContext));
			}
			else if (wellKnownDN == WellKnownDN.SystemContainer)
			{
				propertyValue = string.Concat("CN=System,", this.ExpandWellKnownDN(WellKnownDN.DefaultNamingContext));
			}
			else if (wellKnownDN == WellKnownDN.RidManager)
			{
				propertyValue = string.Concat("CN=RID Manager$,", this.ExpandWellKnownDN(WellKnownDN.SystemContainer));
			}
			else if (wellKnownDN == WellKnownDN.Infrastructure)
			{
				propertyValue = string.Concat("CN=Infrastructure,", this.ExpandWellKnownDN(WellKnownDN.DefaultNamingContext));
			}
			else if (wellKnownDN == WellKnownDN.RootDomainNamingContext)
			{
				DirectoryEntry directoryEntry1 = this.GetCachedDirectoryEntry("RootDSE");
				propertyValue = (string)PropertyManager.GetPropertyValue(this.context, directoryEntry1, PropertyManager.RootDomainNamingContext);
			}
			else
			{
				throw new InvalidEnumArgumentException("dn", (int)dn, typeof(WellKnownDN));
			}
			return propertyValue;
		}
        internal static string ExpandWellKnownDN(DirectoryContext context, WellKnownDN dn)
        {
            switch (dn)
            {
                case WellKnownDN.RootDSE:
                    return "RootDSE";

                case WellKnownDN.DefaultNamingContext:
                {
                    using (DirectoryEntry entry2 = GetDirectoryEntry(context, "RootDSE"))
                    {
                        return (string) PropertyManager.GetPropertyValue(context, entry2, PropertyManager.DefaultNamingContext);
                    }
                }
                case WellKnownDN.SchemaNamingContext:
                {
                    using (DirectoryEntry entry3 = GetDirectoryEntry(context, "RootDSE"))
                    {
                        return (string) PropertyManager.GetPropertyValue(context, entry3, PropertyManager.SchemaNamingContext);
                    }
                }
                case WellKnownDN.ConfigurationNamingContext:
                {
                    using (DirectoryEntry entry4 = GetDirectoryEntry(context, "RootDSE"))
                    {
                        return (string) PropertyManager.GetPropertyValue(context, entry4, PropertyManager.ConfigurationNamingContext);
                    }
                }
                case WellKnownDN.PartitionsContainer:
                    return ("CN=Partitions," + ExpandWellKnownDN(context, WellKnownDN.ConfigurationNamingContext));

                case WellKnownDN.SitesContainer:
                    return ("CN=Sites," + ExpandWellKnownDN(context, WellKnownDN.ConfigurationNamingContext));

                case WellKnownDN.SystemContainer:
                    return ("CN=System," + ExpandWellKnownDN(context, WellKnownDN.DefaultNamingContext));

                case WellKnownDN.RidManager:
                    return ("CN=RID Manager$," + ExpandWellKnownDN(context, WellKnownDN.SystemContainer));

                case WellKnownDN.Infrastructure:
                    return ("CN=Infrastructure," + ExpandWellKnownDN(context, WellKnownDN.DefaultNamingContext));

                case WellKnownDN.RootDomainNamingContext:
                {
                    using (DirectoryEntry entry = GetDirectoryEntry(context, "RootDSE"))
                    {
                        return (string) PropertyManager.GetPropertyValue(context, entry, PropertyManager.RootDomainNamingContext);
                    }
                }
            }
            throw new InvalidEnumArgumentException("dn", (int) dn, typeof(WellKnownDN));
        }
        internal string ExpandWellKnownDN(WellKnownDN dn)
        {
            switch (dn)
            {
            case WellKnownDN.RootDSE:
                return("RootDSE");

            case WellKnownDN.DefaultNamingContext:
            {
                DirectoryEntry cachedDirectoryEntry = this.GetCachedDirectoryEntry("RootDSE");
                return((string)PropertyManager.GetPropertyValue(this.context, cachedDirectoryEntry, PropertyManager.DefaultNamingContext));
            }

            case WellKnownDN.SchemaNamingContext:
            {
                DirectoryEntry directoryEntry = this.GetCachedDirectoryEntry("RootDSE");
                return((string)PropertyManager.GetPropertyValue(this.context, directoryEntry, PropertyManager.SchemaNamingContext));
            }

            case WellKnownDN.ConfigurationNamingContext:
            {
                DirectoryEntry entry4 = this.GetCachedDirectoryEntry("RootDSE");
                return((string)PropertyManager.GetPropertyValue(this.context, entry4, PropertyManager.ConfigurationNamingContext));
            }

            case WellKnownDN.PartitionsContainer:
                return("CN=Partitions," + this.ExpandWellKnownDN(WellKnownDN.ConfigurationNamingContext));

            case WellKnownDN.SitesContainer:
                return("CN=Sites," + this.ExpandWellKnownDN(WellKnownDN.ConfigurationNamingContext));

            case WellKnownDN.SystemContainer:
                return("CN=System," + this.ExpandWellKnownDN(WellKnownDN.DefaultNamingContext));

            case WellKnownDN.RidManager:
                return("CN=RID Manager$," + this.ExpandWellKnownDN(WellKnownDN.SystemContainer));

            case WellKnownDN.Infrastructure:
                return("CN=Infrastructure," + this.ExpandWellKnownDN(WellKnownDN.DefaultNamingContext));

            case WellKnownDN.RootDomainNamingContext:
            {
                DirectoryEntry entry = this.GetCachedDirectoryEntry("RootDSE");
                return((string)PropertyManager.GetPropertyValue(this.context, entry, PropertyManager.RootDomainNamingContext));
            }
            }
            throw new InvalidEnumArgumentException("dn", (int)dn, typeof(WellKnownDN));
        }
        internal string ExpandWellKnownDN(WellKnownDN dn)
        {
            switch (dn)
            {
                case WellKnownDN.RootDSE:
                    return "RootDSE";

                case WellKnownDN.DefaultNamingContext:
                {
                    DirectoryEntry cachedDirectoryEntry = this.GetCachedDirectoryEntry("RootDSE");
                    return (string) PropertyManager.GetPropertyValue(this.context, cachedDirectoryEntry, PropertyManager.DefaultNamingContext);
                }
                case WellKnownDN.SchemaNamingContext:
                {
                    DirectoryEntry directoryEntry = this.GetCachedDirectoryEntry("RootDSE");
                    return (string) PropertyManager.GetPropertyValue(this.context, directoryEntry, PropertyManager.SchemaNamingContext);
                }
                case WellKnownDN.ConfigurationNamingContext:
                {
                    DirectoryEntry entry4 = this.GetCachedDirectoryEntry("RootDSE");
                    return (string) PropertyManager.GetPropertyValue(this.context, entry4, PropertyManager.ConfigurationNamingContext);
                }
                case WellKnownDN.PartitionsContainer:
                    return ("CN=Partitions," + this.ExpandWellKnownDN(WellKnownDN.ConfigurationNamingContext));

                case WellKnownDN.SitesContainer:
                    return ("CN=Sites," + this.ExpandWellKnownDN(WellKnownDN.ConfigurationNamingContext));

                case WellKnownDN.SystemContainer:
                    return ("CN=System," + this.ExpandWellKnownDN(WellKnownDN.DefaultNamingContext));

                case WellKnownDN.RidManager:
                    return ("CN=RID Manager$," + this.ExpandWellKnownDN(WellKnownDN.SystemContainer));

                case WellKnownDN.Infrastructure:
                    return ("CN=Infrastructure," + this.ExpandWellKnownDN(WellKnownDN.DefaultNamingContext));

                case WellKnownDN.RootDomainNamingContext:
                {
                    DirectoryEntry entry = this.GetCachedDirectoryEntry("RootDSE");
                    return (string) PropertyManager.GetPropertyValue(this.context, entry, PropertyManager.RootDomainNamingContext);
                }
            }
            throw new InvalidEnumArgumentException("dn", (int) dn, typeof(WellKnownDN));
        }
Esempio n. 7
0
        internal static string ExpandWellKnownDN(DirectoryContext context, WellKnownDN dn)
        {
            string      propertyValue = null;
            WellKnownDN wellKnownDN   = dn;

            if (wellKnownDN == WellKnownDN.RootDSE)
            {
                propertyValue = "RootDSE";
            }
            else if (wellKnownDN == WellKnownDN.DefaultNamingContext)
            {
                DirectoryEntry directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, "RootDSE");
                try
                {
                    propertyValue = (string)PropertyManager.GetPropertyValue(context, directoryEntry, PropertyManager.DefaultNamingContext);
                }
                finally
                {
                    directoryEntry.Dispose();
                }
            }
            else if (wellKnownDN == WellKnownDN.SchemaNamingContext)
            {
                DirectoryEntry directoryEntry1 = DirectoryEntryManager.GetDirectoryEntry(context, "RootDSE");
                try
                {
                    propertyValue = (string)PropertyManager.GetPropertyValue(context, directoryEntry1, PropertyManager.SchemaNamingContext);
                }
                finally
                {
                    directoryEntry1.Dispose();
                }
            }
            else if (wellKnownDN == WellKnownDN.ConfigurationNamingContext)
            {
                DirectoryEntry directoryEntry2 = DirectoryEntryManager.GetDirectoryEntry(context, "RootDSE");
                try
                {
                    propertyValue = (string)PropertyManager.GetPropertyValue(context, directoryEntry2, PropertyManager.ConfigurationNamingContext);
                }
                finally
                {
                    directoryEntry2.Dispose();
                }
            }
            else if (wellKnownDN == WellKnownDN.PartitionsContainer)
            {
                propertyValue = string.Concat("CN=Partitions,", DirectoryEntryManager.ExpandWellKnownDN(context, WellKnownDN.ConfigurationNamingContext));
            }
            else if (wellKnownDN == WellKnownDN.SitesContainer)
            {
                propertyValue = string.Concat("CN=Sites,", DirectoryEntryManager.ExpandWellKnownDN(context, WellKnownDN.ConfigurationNamingContext));
            }
            else if (wellKnownDN == WellKnownDN.SystemContainer)
            {
                propertyValue = string.Concat("CN=System,", DirectoryEntryManager.ExpandWellKnownDN(context, WellKnownDN.DefaultNamingContext));
            }
            else if (wellKnownDN == WellKnownDN.RidManager)
            {
                propertyValue = string.Concat("CN=RID Manager$,", DirectoryEntryManager.ExpandWellKnownDN(context, WellKnownDN.SystemContainer));
            }
            else if (wellKnownDN == WellKnownDN.Infrastructure)
            {
                propertyValue = string.Concat("CN=Infrastructure,", DirectoryEntryManager.ExpandWellKnownDN(context, WellKnownDN.DefaultNamingContext));
            }
            else if (wellKnownDN == WellKnownDN.RootDomainNamingContext)
            {
                DirectoryEntry directoryEntry3 = DirectoryEntryManager.GetDirectoryEntry(context, "RootDSE");
                try
                {
                    propertyValue = (string)PropertyManager.GetPropertyValue(context, directoryEntry3, PropertyManager.RootDomainNamingContext);
                }
                finally
                {
                    directoryEntry3.Dispose();
                }
            }
            else
            {
                throw new InvalidEnumArgumentException("dn", (int)dn, typeof(WellKnownDN));
            }
            return(propertyValue);
        }
Esempio n. 8
0
 internal static DirectoryEntry GetDirectoryEntry(DirectoryContext context, WellKnownDN dn)
 {
     return(DirectoryEntryManager.GetDirectoryEntry(context, DirectoryEntryManager.ExpandWellKnownDN(context, dn)));
 }
Esempio n. 9
0
 internal DirectoryEntry GetCachedDirectoryEntry(WellKnownDN dn)
 {
     return(this.GetCachedDirectoryEntry(this.ExpandWellKnownDN(dn)));
 }
Esempio n. 10
0
        internal static string ExpandWellKnownDN(DirectoryContext context, WellKnownDN dn)
        {
            string distinguishedName = null;

            switch (dn)
            {
            case WellKnownDN.RootDSE:
            {
                distinguishedName = "RootDSE";
                break;
            }

            case WellKnownDN.RootDomainNamingContext:
            {
                DirectoryEntry rootDSE = GetDirectoryEntry(context, "RootDSE");

                try
                {
                    distinguishedName = (string)PropertyManager.GetPropertyValue(context, rootDSE, PropertyManager.RootDomainNamingContext);
                }
                finally
                {
                    rootDSE.Dispose();
                }
                break;
            }

            case WellKnownDN.DefaultNamingContext:
            {
                DirectoryEntry rootDSE = GetDirectoryEntry(context, "RootDSE");
                try
                {
                    distinguishedName = (string)PropertyManager.GetPropertyValue(context, rootDSE, PropertyManager.DefaultNamingContext);
                }
                finally
                {
                    rootDSE.Dispose();
                }
                break;
            }

            case WellKnownDN.SchemaNamingContext:
            {
                DirectoryEntry rootDSE = GetDirectoryEntry(context, "RootDSE");
                try
                {
                    distinguishedName = (string)PropertyManager.GetPropertyValue(context, rootDSE, PropertyManager.SchemaNamingContext);
                }
                finally
                {
                    rootDSE.Dispose();
                }
                break;
            }

            case WellKnownDN.ConfigurationNamingContext:
            {
                DirectoryEntry rootDSE = GetDirectoryEntry(context, "RootDSE");
                try
                {
                    distinguishedName = (string)PropertyManager.GetPropertyValue(context, rootDSE, PropertyManager.ConfigurationNamingContext);
                }
                finally
                {
                    rootDSE.Dispose();
                }
                break;
            }

            case WellKnownDN.PartitionsContainer:
            {
                distinguishedName = "CN=Partitions," + ExpandWellKnownDN(context, WellKnownDN.ConfigurationNamingContext);
                break;
            }

            case WellKnownDN.SitesContainer:
            {
                distinguishedName = "CN=Sites," + ExpandWellKnownDN(context, WellKnownDN.ConfigurationNamingContext);
                break;
            }

            case WellKnownDN.SystemContainer:
            {
                distinguishedName = "CN=System," + ExpandWellKnownDN(context, WellKnownDN.DefaultNamingContext);
                break;
            }

            case WellKnownDN.RidManager:
            {
                distinguishedName = "CN=RID Manager$," + ExpandWellKnownDN(context, WellKnownDN.SystemContainer);
                break;
            }

            case WellKnownDN.Infrastructure:
            {
                distinguishedName = "CN=Infrastructure," + ExpandWellKnownDN(context, WellKnownDN.DefaultNamingContext);
                break;
            }

            default:
                // should not happen
                throw new InvalidEnumArgumentException("dn", (int)dn, typeof(WellKnownDN));
            }
            return(distinguishedName);
        }
Esempio n. 11
0
        internal static string ExpandWellKnownDN(DirectoryContext context, WellKnownDN dn)
        {
            string distinguishedName = null;

            switch (dn)
            {
                case WellKnownDN.RootDSE:
                    {
                        distinguishedName = "RootDSE";
                        break;
                    }
                case WellKnownDN.RootDomainNamingContext:
                    {
                        DirectoryEntry rootDSE = GetDirectoryEntry(context, "RootDSE");

                        try
                        {
                            distinguishedName = (string)PropertyManager.GetPropertyValue(context, rootDSE, PropertyManager.RootDomainNamingContext);
                        }
                        finally
                        {
                            rootDSE.Dispose();
                        }
                        break;
                    }
                case WellKnownDN.DefaultNamingContext:
                    {
                        DirectoryEntry rootDSE = GetDirectoryEntry(context, "RootDSE");
                        try
                        {
                            distinguishedName = (string)PropertyManager.GetPropertyValue(context, rootDSE, PropertyManager.DefaultNamingContext);
                        }
                        finally
                        {
                            rootDSE.Dispose();
                        }
                        break;
                    }
                case WellKnownDN.SchemaNamingContext:
                    {
                        DirectoryEntry rootDSE = GetDirectoryEntry(context, "RootDSE");
                        try
                        {
                            distinguishedName = (string)PropertyManager.GetPropertyValue(context, rootDSE, PropertyManager.SchemaNamingContext);
                        }
                        finally
                        {
                            rootDSE.Dispose();
                        }
                        break;
                    }
                case WellKnownDN.ConfigurationNamingContext:
                    {
                        DirectoryEntry rootDSE = GetDirectoryEntry(context, "RootDSE");
                        try
                        {
                            distinguishedName = (string)PropertyManager.GetPropertyValue(context, rootDSE, PropertyManager.ConfigurationNamingContext);
                        }
                        finally
                        {
                            rootDSE.Dispose();
                        }
                        break;
                    }
                case WellKnownDN.PartitionsContainer:
                    {
                        distinguishedName = "CN=Partitions," + ExpandWellKnownDN(context, WellKnownDN.ConfigurationNamingContext);
                        break;
                    }
                case WellKnownDN.SitesContainer:
                    {
                        distinguishedName = "CN=Sites," + ExpandWellKnownDN(context, WellKnownDN.ConfigurationNamingContext);
                        break;
                    }
                case WellKnownDN.SystemContainer:
                    {
                        distinguishedName = "CN=System," + ExpandWellKnownDN(context, WellKnownDN.DefaultNamingContext);
                        break;
                    }
                case WellKnownDN.RidManager:
                    {
                        distinguishedName = "CN=RID Manager$," + ExpandWellKnownDN(context, WellKnownDN.SystemContainer);
                        break;
                    }
                case WellKnownDN.Infrastructure:
                    {
                        distinguishedName = "CN=Infrastructure," + ExpandWellKnownDN(context, WellKnownDN.DefaultNamingContext);
                        break;
                    }
                default:
                    // should not happen
                    throw new InvalidEnumArgumentException("dn", (int)dn, typeof(WellKnownDN));
            }
            return distinguishedName;
        }
Esempio n. 12
0
 internal static DirectoryEntry GetDirectoryEntry(DirectoryContext context, WellKnownDN dn)
 {
     return GetDirectoryEntry(context, ExpandWellKnownDN(context, dn));
 }
Esempio n. 13
0
 internal DirectoryEntry GetCachedDirectoryEntry(WellKnownDN dn)
 {
     return GetCachedDirectoryEntry(ExpandWellKnownDN(dn));
 }
Esempio n. 14
0
		internal static string ExpandWellKnownDN(DirectoryContext context, WellKnownDN dn)
		{
			string propertyValue = null;
			WellKnownDN wellKnownDN = dn;
			if (wellKnownDN == WellKnownDN.RootDSE)
			{
				propertyValue = "RootDSE";
			}
			else if (wellKnownDN == WellKnownDN.DefaultNamingContext)
			{
				DirectoryEntry directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, "RootDSE");
				try
				{
					propertyValue = (string)PropertyManager.GetPropertyValue(context, directoryEntry, PropertyManager.DefaultNamingContext);
				}
				finally
				{
					directoryEntry.Dispose();
				}
			}
			else if (wellKnownDN == WellKnownDN.SchemaNamingContext)
			{
				DirectoryEntry directoryEntry1 = DirectoryEntryManager.GetDirectoryEntry(context, "RootDSE");
				try
				{
					propertyValue = (string)PropertyManager.GetPropertyValue(context, directoryEntry1, PropertyManager.SchemaNamingContext);
				}
				finally
				{
					directoryEntry1.Dispose();
				}
			}
			else if (wellKnownDN == WellKnownDN.ConfigurationNamingContext)
			{
				DirectoryEntry directoryEntry2 = DirectoryEntryManager.GetDirectoryEntry(context, "RootDSE");
				try
				{
					propertyValue = (string)PropertyManager.GetPropertyValue(context, directoryEntry2, PropertyManager.ConfigurationNamingContext);
				}
				finally
				{
					directoryEntry2.Dispose();
				}
			}
			else if (wellKnownDN == WellKnownDN.PartitionsContainer)
			{
				propertyValue = string.Concat("CN=Partitions,", DirectoryEntryManager.ExpandWellKnownDN(context, WellKnownDN.ConfigurationNamingContext));
			}
			else if (wellKnownDN == WellKnownDN.SitesContainer)
			{
				propertyValue = string.Concat("CN=Sites,", DirectoryEntryManager.ExpandWellKnownDN(context, WellKnownDN.ConfigurationNamingContext));
			}
			else if (wellKnownDN == WellKnownDN.SystemContainer)
			{
				propertyValue = string.Concat("CN=System,", DirectoryEntryManager.ExpandWellKnownDN(context, WellKnownDN.DefaultNamingContext));
			}
			else if (wellKnownDN == WellKnownDN.RidManager)
			{
				propertyValue = string.Concat("CN=RID Manager$,", DirectoryEntryManager.ExpandWellKnownDN(context, WellKnownDN.SystemContainer));
			}
			else if (wellKnownDN == WellKnownDN.Infrastructure)
			{
				propertyValue = string.Concat("CN=Infrastructure,", DirectoryEntryManager.ExpandWellKnownDN(context, WellKnownDN.DefaultNamingContext));
			}
			else if (wellKnownDN == WellKnownDN.RootDomainNamingContext)
			{
				DirectoryEntry directoryEntry3 = DirectoryEntryManager.GetDirectoryEntry(context, "RootDSE");
				try
				{
					propertyValue = (string)PropertyManager.GetPropertyValue(context, directoryEntry3, PropertyManager.RootDomainNamingContext);
				}
				finally
				{
					directoryEntry3.Dispose();
				}
			}
			else
			{
				throw new InvalidEnumArgumentException("dn", (int)dn, typeof(WellKnownDN));
			}
			return propertyValue;
		}