internal static ActiveDirectoryGroup[] GetGroups(string domain)
        {
            ADWrapper ad = new ADWrapper(domain, ActiveDirectoryService.CnnStringName, performCustomWindowsContextImpersonalization);

            List <ADGroup> list = ad.Groups_GetAll();

            ad.Dispose();

            if (list.Count != 0)
            {
                var userList = from u in list select new ActiveDirectoryGroup(u);

                return(userList.ToArray <ActiveDirectoryGroup>());
            }
            else
            {
                return(null);
            }
        }