I am trying to request AD in an ASP.Net (4.0) application that runs on Windows Server 2008 R2 (IIS7 is installed). (It also does not work at startup as application 2.0)
This is not new to me, as I have done it many times before. I wrote a small ASP.Net program that works fine on my machine (Windows XP with IIS6), but does not work when launched in the 2008 window.
(As a result, you see a list of groups of which the user is a member in the text box)
(on button_click) var userName = txtUserName.Text; if (userName.Trim().Length == 0) { txtResults.Text = "-- MISSING USER NAME --"; return; } var entry = new DirectoryEntry("LDAP://blah.blah/DC=blah,DC=blah", "cn=acct, dc=blah, dc=blah", "pass"); var search = new DirectorySearcher(entry); search.Filter = "(SAMAccountName=" + userName + ")"; search.PropertiesToLoad.Add("memberOf"); var groupsList = new StringBuilder(); var result = search.FindOne(); if (result != null) { int groupCount = result.Properties["memberOf"].Count; for (int counter = 0; counter < groupCount; counter++) { groupsList.Append((string)result.Properties["memberOf"][counter]); groupsList.Append("\r\n"); } } txtResults.Text = groupsList.ToString();
When I run this code, I get the following search error. FindOne ():
System.DirectoryServices.DirectoryServicesCOMException (0x8007203B): A local error has occurred. at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) at System.DirectoryServices.DirectoryEntry.Bind() at System.DirectoryServices.DirectoryEntry.get_AdsObject() at System.DirectoryServices.DirectorySearcher.FindAll(Boolean findMoreThanOne) at System.DirectoryServices.DirectorySearcher.FindOne() at WebApplication1._Default.btnSearch_Click(Object sender, EventArgs e)
We did a lot of research with this and bonded every IIS7 setting that we can think of, but don't go yet. Any clues?
source share