Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ActiveDirectory programming is not recurning anything

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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

670 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