This is the below code which I used to get the web reference using the title of the web site. The problem is the current user is not a member of all sub site so I'm getting access denied error.
User A have rights to: Web1, Web2 (no problem with code)
User B have rights to: Web1 (problem with code because he doesn't have rights to web2)
int projectid = GetProjectID(SPContext.Current.Web.Title, Url); string projecttitle = SPContext.Current.Web.Title; var nodename = currentWeb.ChildNodes.Cast<SiteMapNode>().FirstOrDefault(node => node.Title == projecttitle);