If you need to check that the current user is anonymous and does not already exist in your AD you can do so by checking his SPUser.LoginName.
Here is a little sample
public static bool IsAnnonymous(this SPUser user)
{
return user == null || String.IsNullOrEmpty(user.LoginName);
}
public static void IsUserAnnonymous(this SPUser user)
{
if (user.IsAnnonymous())
{
// In Case the user is annonymous then redirect to AccessDenied.aspx Page
response.Redirect("/_layouts/AccessDenied.aspx", true);
}
}
You can call the method by
IsUserAnnonymous(SPContext.web.Current.User);
No comments:
Post a Comment