Solved

ActiveDirectory programming is not recurning anything

Posted on 2007-11-19
1
261 Views
Last Modified: 2008-02-01
Hi folks.  We are trying to do some ActiveDirectory programming, see the code snip below.  The purpose is by entering a GroupName, we want to list the members of that group.  It works fine on local development machine with IIS running, but it returns nothing when we pushed it to the web server.  Any idea what is going on?  Thanks.

      protected void Page_Load(object sender, EventArgs e)
      {
         GetMembers();
      }

      private void GetMembers()
      {
         try
         {
            DirectoryEntry ent = new DirectoryEntry("GC://cdc.gov/DC=cdc,DC=gov");
            DirectorySearcher srch = new DirectorySearcher(ent);
            srch.Filter = "(CN=DLS_Informatics_Team)"; //DLS_Informatics_Team: the group name.  Manually put in for development purposes.

            SearchResultCollection coll = srch.FindAll();

            ArrayList userNames = new ArrayList();
            foreach (SearchResult rs in coll)
            {
               ResultPropertyCollection resultPropColl = rs.Properties;
               foreach (Object memberColl in resultPropColl["member"])
               {
                  DirectoryEntry gpMemberEntry = new DirectoryEntry("LDAP://cdc.gov/" + memberColl);
                  System.DirectoryServices.PropertyCollection userProps = gpMemberEntry.Properties;
                  object obSam = userProps["sAMAccountName"].Value;
                  object obUserName = userProps["displayname"].Value;
                 
                  if (obSam !=null)
                  {
                     Response.Write(obSam.ToString() + " - " + obUserName.ToString() + "<br>");
                  }
               }
            }
         }
         catch (Exception ex)
         {
            Response.Write(ex.Message);
         }
      }
0
Comment
Question by:DigiFoto
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 18

Accepted Solution

by:
tusharashah earned 500 total points
ID: 20315440
There are 2 things that may have gone wrong here:
1). Web Server on different domain (less chances!)
2). The account that Website on web server is running under do not have enough permission to AD box

If it's the 2nd issue.. you can change the user the WebSite is running under from IIS > Website Properties > Directory Security. or you can directly type your password in web.config like following:

<identity impersonate="true" userName="[Domain\AdminAccount]" password="[password]" />
[in both cases you'll need to set the impersonation = 'true' in web.config for website]
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question