Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ActiveDirectory programming is not recurning anything

Posted on 2007-11-19
1
Medium Priority
?
265 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 1500 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

Industry Leaders: 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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Integration Management Part 2
Screencast - Getting to Know the Pipeline
Suggested Courses

876 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