Ejemplo n.º 1
0
        internal static string GetCurrentServerFromSession(IDirectorySession session)
        {
            string text = session.ServerSettings.PreferredGlobalCatalog(session.SessionSettings.GetAccountOrResourceForestFqdn());

            if (string.IsNullOrEmpty(text))
            {
                ADObjectId           adobjectId           = null;
                PooledLdapConnection pooledLdapConnection = null;
                try
                {
                    pooledLdapConnection = session.GetReadConnection(null, ref adobjectId);
                    text = pooledLdapConnection.ServerName;
                }
                finally
                {
                    if (pooledLdapConnection != null)
                    {
                        pooledLdapConnection.ReturnToPool();
                    }
                }
            }
            return(text);
        }