Your example always returns on the first iteration of the loop - obviously not what you want...
The error is there because if there is nothing contained in ADGroups, then no return statement is executed.
You want something like the following:
VB Code:
public static bool IsMember(List<string> ADGroups) { System.Security.Principal.IPrincipal User1; User1 = System.Web.HttpContext.Current.User; foreach (string xx in ADGroups) { string sADRole = "fhlbsf-i.com\\"+ xx.ToString(); if ((User1.IsInRole(sADRole) == true)) { return true; } } return false; }




Reply With Quote