This project has moved and is read-only. For the latest updates, please go here.

Error trying to get TD to run using AD security

Aug 26, 2011 at 9:35 PM
Getting a Value cannot be null exception when trying to run new installation of TD against our AD.  See the 
Line 3:      var controller = ViewContext.Controller as TicketDesk.Web.Client.Controllers.ApplicationController;
Line 4:  
Line 5:      if (Request.IsAuthenticated && controller != null && controller.Security.IsInValidTdUserRole())
Line 6:      {
Line 7:          using (Html.BeginForm(MVC.TicketSearch.Index(), FormMethod.Post, new { @class = "searchArea" }))

Stack Trace:

[ArgumentNullException: Value cannot be null.
Parameter name: value]
   System.Runtime.Caching.MemoryCacheEntry..ctor(String key, Object value, DateTimeOffset absExp, TimeSpan slidingExp, CacheItemPriority priority, Collection`1 dependencies, CacheEntryRemovedCallback removedCallback, MemoryCache cache) +470
   System.Runtime.Caching.MemoryCache.AddOrGetExistingInternal(String key, Object value, CacheItemPolicy policy) +620
   System.Runtime.Caching.ObjectCache.Add(String key, Object value, CacheItemPolicy policy, String regionName) +25
   TicketDesk.Domain.Services.AdSecurityCacheService.SetCache(ObjectCache cache, String key, Object value, CacheItemPolicy policy) in C:\Projects\Personal\VS2010\TicketDesk\TicketDesk-2-branch\TicketDesk.Domain\Services\AdSecurityCacheService.cs:142
   TicketDesk.Domain.Services.AdSecurityCacheService.GetRoleMembers(String groupName) in C:\Projects\Personal\VS2010\TicketDesk\TicketDesk-2-branch\TicketDesk.Domain\Services\AdSecurityCacheService.cs:81
   TicketDesk.Domain.Repositories.AdSecurityRepository.IsUserInRoleName(String userName, String roleName) in C:\Projects\Personal\VS2010\TicketDesk\TicketDesk-2-branch\TicketDesk.Domain\Repositories\AdSecurityRepository.cs:77
   TicketDesk.Domain.Services.SecurityService.IsInValidTdUserRole() in C:\Projects\Personal\VS2010\TicketDesk\TicketDesk-2-branch\TicketDesk.Domain\Services\SecurityService.cs:304
   ASP.views_shared_quickseach_ascx.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in e:\TicketDesk\Views\Shared\QuickSeach.ascx:5
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +131
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +246
   System.Web.Mvc.ViewPage.Render(HtmlTextWriter writer) +85
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4943

Any help appreciated!



Aug 27, 2011 at 7:20 AM

The most likely problem is that the web.config appSettings values are not correct for your environment (or are missing completely). It's hard to know for sure without more information though, but that seems a likely issue. The part of the code reporting the problem is working with caching the members of the the AD groups that TicketDesk is using. Beyond that, it's difficult to tell exactly what is null, but the odds are that the list of members fetched back from AD is empty for one or more of the groups TD is checking.

This is, in a way, a bug. I have marked it to be fixed. But the solution in your case is to make sure TD has the right AD groups specified in web.config, and that the groups all contain at least one user account.    

Aug 29, 2011 at 2:44 PM

The AD groups are specified in the web.config and each group has multiple members.  Any other ideas?  I'll DL the source later today and see if I can pinpoint the problem.



Aug 30, 2011 at 8:12 PM

i have no other ideas. With that stack trace the only clear cause I can see from an audit of the code is if the AD query returned zero users for one of the groups it was checking (but did not throw an error). I can't see any other unguarded openings for a null ref, though there could easily be something I'm not seeing from a simple code audit, and I don't have good unit tests for the AD repository (AD is not fun to mock for testing at that level).