Solved

how to connect to query AD if the web server is not on the domain

Posted on 2011-09-23
5
135 Views
Last Modified: 2012-05-12
I have the following code that works great in DEV because the DEV server is on the domain. However when I deploy the files to the web server (not on the domain), my page does not work. Do I put the connection for active directory in the web.config file, or does it get embedded into the c# (sorry, I am new to web development)?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.DirectoryServices;
using System.DirectoryServices.ActiveDirectory;
using System.Text;
using System.Collections;
using System.DirectoryServices;
using System.DirectoryServices.ActiveDirectory;


namespace MasterPageTst.SA
{
    public partial class SupportRequestSA : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //I tried this with both lines below, I could not get either to work. The Sys Admins created a user named "MyDomain\adquery" for me
			DirectoryEntry group = new DirectoryEntry("LDAP://CN=CSR Admins,OU=ServiceAccounts,DC=MyDomain,DC=COM");
            //DirectoryEntry group = new DirectoryEntry("LDAP://CN=CSR Admins,OU=ServiceAccounts,DC=MyDomain,DC=COM", "MyDomain\adquery", "password123456");
            ArrayList ArrUsers = new ArrayList();
            object members = group.Invoke("Members", null);
            foreach (object member in (IEnumerable)members)
            {
                DirectoryEntry x = new DirectoryEntry(member);
                //Console.WriteLine(x.Name);
                ArrUsers.Add(x.Name.Substring(3));
                //ArrUsers.Add(x.Name.Replace("CN=", "")) ;
                //(Replace("CN=", "")
                //ArrUsers.Add(x.Name.Replace("CN=", ""));
            }
            DropDownList3.DataSource = ArrUsers;
            DropDownList3.DataBind();
        }


    }
}

Open in new window


My goal is have the web page build a drop down list from all the users in an AD group....please help....
0
Comment
Question by:sqlagent007
  • 3
  • 2
5 Comments
 
LVL 49

Accepted Solution

by:
Gustav Brock earned 500 total points
ID: 36594837
First, check that the web server knows where to find a local Domain Controller.

Second, if the web server is in-house, why not enter the web server in AD?
If the web server is not in-house it is likely not able to see your local Domain Controllers.

/gustav
0
 
LVL 1

Author Comment

by:sqlagent007
ID: 36595234
The web server is in house, and the security team does not want the web server to be on the domain.
0
 
LVL 49

Expert Comment

by:Gustav Brock
ID: 36595506
So how will your site know about your AD domain when the server doesn't?

/gustav
0
 
LVL 1

Author Closing Comment

by:sqlagent007
ID: 36597072
I got them to put the server on the domain...all is good now.
0
 
LVL 49

Expert Comment

by:Gustav Brock
ID: 36597316
Fine! They probably realised that it doesn't hurt.

/gustav
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

820 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