Solved

ActiveDirectory programming is not recurning anything

Posted on 2007-11-19
1
257 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
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This video discusses moving either the default database or any database to a new volume.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

758 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now