locked
How to retrieve users from the "Domain Users" group RRS feed

  • Question

  • User-2137316273 posted

    Hi

    I want to use the Domain Users group to show all the users in a dropdown box. For some or other reason I cannot return all the users when looking for everyone under the domain so instead I was thinking of using the domain users group.

    This is part of my code:

    using (DirectoryEntry de = new DirectoryEntry(xmlADPath, xmlADUser, xmlADPw))
                    {
                        xnMyForm.SelectSingleNode("/my:myFields/my:secHidden/my:txtDebug", ns).SetValue(xnMyForm.SelectSingleNode("/my:myFields/my:secHidden/my:txtDebug", ns).Value + "Entered Using DirectoryEntry de = new DirectoryEntry(xmlADPath, xmlADUser, xmlADPw)");
    
                        de.AuthenticationType = AuthenticationTypes.Delegation;
                        DirectorySearcher deSearch = new DirectorySearcher(de);
                        deSearch.Filter = "(&(objectClass=group)(cn=" + xmlADGroup + "))";
                        SearchResult results = null;
                        try
                        {
                            results = deSearch.FindOne();
                        }
                        catch (Exception e) { xnMyForm.SelectSingleNode("/my:myFields/my:secHidden/my:txtDebug", ns).SetValue(xnMyForm.SelectSingleNode("/my:myFields/my:secHidden/my:txtDebug", ns).Value + "Exception " + e.ToString()); }
                        if (results != null)
                        {
                            xnMyForm.SelectSingleNode("/my:myFields/my:secHidden/my:txtDebug", ns).SetValue(xnMyForm.SelectSingleNode("/my:myFields/my:secHidden/my:txtDebug", ns).Value + "Entered if statement - results not null");
    
                            using (DirectoryEntry deGroup = new DirectoryEntry(xmlADPath, xmlADUser, xmlADPw, AuthenticationTypes.Secure))
                            {
                                xnMyForm.SelectSingleNode("/my:myFields/my:secHidden/my:txtDebug", ns).SetValue(xnMyForm.SelectSingleNode("/my:myFields/my:secHidden/my:txtDebug", ns).Value + "Entered second using statement");
    
                                System.DirectoryServices.PropertyCollection pcoll = deGroup.Properties;
                                int n = pcoll["member"].Count;
                                for (int l = 0; l < n; l++)
     
    I was struggeling with this code for a while but found out that the "member" attribute is not set in active directory. Is there a way that I can either set the property or use another group with all the domain users or retrieve "ALL" the users from the domain. 
    I have a big rpoblem with this and I do not want to ask the client to maintain a group with all the users as this could bring up some problems!
     
    Any suggestions?


     

    Wednesday, July 7, 2010 5:05 AM

Answers

  • User1508394307 posted

    Please see my last post here regarding how to get all users from the domain.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 7, 2010 5:53 PM