Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.NET MVC Active Directory code to retrieve all users stops working when deployed to IIS 7
    primarykey
    data
    text
    <p>I have an intranet ASP.NET MVC3 web application that is using Windows authentication with .NET Framework 4. All my code is working as far as authenticating the users. I am using Windows Authentication for the baseline authentication, and then link the Active Directory user to a user in a table in SQL Server 2008 for additional user properties specific to my application. All of that is working fine.</p> <p>There is a section of the site where admins can select Active Directory users to add to the SQL user table (see above) and put in their site specific properties (IsAdmin, ShoeSize, etc.). On this screen, there is a drop down list that I populate to retrieve all Active Directory from a custom object I created that just holds the username and full name properties of the Active Directory user. Here is this code for that:</p> <pre><code> public IQueryable&lt;ActiveDirectoryUser&gt; ActiveDirectoryUsers { get { // get list of users in the Active Directory DirectoryEntry dirEntry = new DirectoryEntry("WinNT://" + Environment.UserDomainName); List&lt;DirectoryEntry&gt; activeDirectoryUsers = dirEntry.Children.Cast&lt;DirectoryEntry&gt;() .Where(c =&gt; c.SchemaClassName == "User").ToList(); // populate a custom class I have to hold the active directory user's username and full name property values return activeDirectoryUsers .Where(u =&gt; !string.IsNullOrEmpty(u.Properties["FullName"].Value.ToString())) .Select(u =&gt; new ActiveDirectoryUser() { NetworkId = String.Format(@"{0}\{1}", Environment.UserDomainName, u.Properties["Name"].Value), FullName = u.Properties["FullName"].Value.ToString() }).AsQueryable(); } } </code></pre> <p>For some reason, this code returns no results when the web application is deployed to IIS 7. However, this works perfectly when running the site from IIS Express in Visual Studio. Any ideas of why this would be happening? I have been looking for IIS settings as the culprit, but have not found anything helpful. Do I need to change the way I am retrieving the Active Directory users? Thank you!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload