Пример #1
0
        internal string GetServerName()
        {
            if (this.serverName == null)
            {
                DirectoryContextType directoryContextType = this.contextType;
                switch (directoryContextType)
                {
                case DirectoryContextType.Domain:
                case DirectoryContextType.Forest:
                {
                    if (this.name == null || this.contextType == DirectoryContextType.Forest && this.isCurrentForest())
                    {
                        this.serverName = DirectoryContext.GetLoggedOnDomain();
                        break;
                    }
                    else
                    {
                        this.serverName = DirectoryContext.GetDnsDomainName(this.name);
                        break;
                    }
                }

                case DirectoryContextType.DirectoryServer:
                {
                    this.serverName = this.name;
                    break;
                }

                case DirectoryContextType.ConfigurationSet:
                {
                    AdamInstance adamInstance = ConfigurationSet.FindAnyAdamInstance(this);
                    try
                    {
                        this.serverName = adamInstance.Name;
                        break;
                    }
                    finally
                    {
                        adamInstance.Dispose();
                    }
                }

                case DirectoryContextType.ApplicationPartition:
                {
                    this.serverName = this.name;
                    break;
                }
                }
            }
            return(this.serverName);
        }
        internal string GetServerName()
        {
            if (this.serverName == null)
            {
                switch (this.contextType)
                {
                case DirectoryContextType.Domain:
                case DirectoryContextType.Forest:
                    goto Label_004A;

                case DirectoryContextType.DirectoryServer:
                    this.serverName = this.name;
                    break;

                case DirectoryContextType.ConfigurationSet:
                    using (AdamInstance instance = ConfigurationSet.FindAnyAdamInstance(this))
                    {
                        this.serverName = instance.Name;
                        break;
                    }
                    goto Label_004A;

                case DirectoryContextType.ApplicationPartition:
                    this.serverName = this.name;
                    break;
                }
            }
            goto Label_009D;
Label_004A:
            if ((this.name == null) || ((this.contextType == DirectoryContextType.Forest) && this.isCurrentForest()))
            {
                this.serverName = GetLoggedOnDomain();
            }
            else
            {
                this.serverName = GetDnsDomainName(this.name);
            }
Label_009D:
            return(this.serverName);
        }
Пример #3
0
        internal string GetServerName()
        {
            if (serverName == null)
            {
                switch (_contextType)
                {
                case DirectoryContextType.ConfigurationSet:
                {
                    AdamInstance adamInst = ConfigurationSet.FindAnyAdamInstance(this);
                    try
                    {
                        serverName = adamInst.Name;
                    }
                    finally
                    {
                        adamInst.Dispose();
                    }
                    break;
                }

                case DirectoryContextType.Domain:
                case DirectoryContextType.Forest:
                {
                    //
                    // if the target is not specified OR
                    // if the forest name was explicitly specified and the forest is the same as the current forest
                    // we want to find a DC in the current domain
                    //
                    if ((_name == null) || ((_contextType == DirectoryContextType.Forest) && (isCurrentForest())))
                    {
                        serverName = GetLoggedOnDomain();
                    }
                    else
                    {
                        serverName = GetDnsDomainName(_name);
                    }
                    break;
                }

                case DirectoryContextType.ApplicationPartition:
                {
                    // if this is an appNC the target should not be null
                    Debug.Assert(_name != null);

                    serverName = _name;
                    break;
                }

                case DirectoryContextType.DirectoryServer:
                {
                    // this should not happen (We should have checks for this earlier itself)
                    Debug.Assert(_name != null);
                    serverName = _name;
                    break;
                }

                default:
                {
                    Debug.Fail("DirectoryContext::GetServerName - Unknown contextType");
                    break;
                }
                }
            }

            return(serverName);
        }