﻿namespace Novell.Directory.Ldap
{
    /// <summary>
    /// Extension Methods for <see cref="ILdapConnection"/> to
    /// avoid bloating that interface.
    /// </summary>
    public static class LdapConnectionExtensionMethods
    {
        /// <summary>
        /// Get some common Attributes from the Root DSE.
        /// This is really just a specialized <see cref="LdapSearchRequest"/>
        /// to handle getting some commonly requested information.
        /// </summary>
        public static RootDseInfo GetRootDseInfo(this ILdapConnection conn)
        {
            var searchResults = conn.Search("", LdapConnection.ScopeBase, "(objectClass=*)", new string[] { "*", "supportedExtension" }, false);
            if (searchResults.HasMore())
            {
                var sr = searchResults.Next();
                return new RootDseInfo(sr);
            }
            return null;
        }
    }
}

﻿namespace Novell.Directory.Ldap
{
    /// <summary>
    /// Extension Methods for <see cref="ILdapConnection"/> to
    /// avoid bloating that interface.
    /// </summary>
    public static class LdapConnectionExtensionMethods
    {
        /// <summary>
        /// Get some common Attributes from the Root DSE.
        /// This is really just a specialized <see cref="LdapSearchRequest"/>
        /// to handle getting some commonly requested information.
        /// </summary>
        public static RootDseInfo GetRootDseInfo(this ILdapConnection conn)
        {
            var searchResults = conn.Search("", LdapConnection.ScopeBase, "(objectClass=*)", new string[] { "*", "+", "supportedExtension" }, false);
            if (searchResults.HasMore())
            {
                var sr = searchResults.Next();
                return new RootDseInfo(sr);
            }
            return null;
        }
    }
}

Add "+" to attributes to fetch since ApacheDS doesn't return all on * and AD doesn't return anything on +
GetRootDseInfo: Add "+" to attributes to fetch since ApacheDS doesn't return all on * and AD doesn't return anything on +
