/// <summary>
 /// Executes the LDAP query.
 /// </summary>
 /// <param name="lDapQuery">The l dap query.</param>
 /// <returns></returns>
 public static bool TestLDAPQuery(string lDapQuery)
 {
     try
     {
         if (String.IsNullOrEmpty(lDapQuery))
         {
             return(true);
         }
         if (String.IsNullOrEmpty(lDapQuery.Trim()))
         {
             return(true);
         }
         DirectoryEntry root = DirectoryServicesUtils.newDirectoryEntry("LDAP://" + (DirectoryServicesUtils.GetRootDSEPart(lDapQuery) ?? SqlAzManStorage.RootDSEPath));
         root.RefreshCache();
         DirectorySearcher searcher = new DirectorySearcher(root, DirectoryServicesUtils.GetLDAPQueryPart(lDapQuery), new string[] { "objectSid" });
         searcher.FindOne();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
 /// <summary>
 /// Executes the LDAP query.
 /// </summary>
 /// <param name="lDapQuery">The l dap query.</param>
 /// <returns></returns>
 public static SearchResultCollection ExecuteLDAPQuery(string lDapQuery)
 {
     try
     {
         DirectoryEntry root = DirectoryServicesUtils.newDirectoryEntry("LDAP://" + (DirectoryServicesUtils.GetRootDSEPart(lDapQuery) ?? SqlAzManStorage.RootDSEPath));
         root.RefreshCache();
         DirectorySearcher searcher = new DirectorySearcher(root, DirectoryServicesUtils.GetLDAPQueryPart(lDapQuery), new string[] { "objectSid" });
         return(searcher.FindAll());
     }
     catch
     {
         throw;
     }
 }