I followed this article to display sub-sites on site collection's home page. I works fine when user have contribute access. But user with read or view only gets Access Denied. What are my options so I can be viewable for everyone with any permission(s).
It worked after i used SPSecurity.RunWithElevatedPrivileges(delegate() to wrap it around.
One thing to check before resorting to runwithelevatedprivileges is that the page you're showing to the user is both 'published' and 'approved' otherwise strange things can happen with permissions
A couple of things to note:
When you wrap your code with RWEP you will override the normal security trimming, and hence when users click the sites they are not allowed to see (this is why the code fails with access denied, since you are not allowed to see all elements in the SPWebCollection). A better alternative is to use SPWeb.GetSubWebForCurrentUser.
Also the code you point to have memory leak issues: you should dispose SPSite and SPWeb controls created by yourself. Find a good guidance here on how to correctly dispose webs and sites.
Also beware that if you have alot of sub sites touching SPWebCollection (rootSite.Webs) could be an expensive operation.