try
{
string strAllUsers = string.Empty;
SPSecurity.RunWithElevatedPrivileges(delegate()
{
strAllUsers += "<Table width='100%' cellpadding='0' cellspacing='0'>";
strAllUsers += "<Tr>";
strAllUsers += "<Td colspan='3' bgcolor='#add8e6'>";
strAllUsers += "</Td>";
strAllUsers += "</Tr>";
strAllUsers += "<Tr>";
strAllUsers += "<Td colspan='3' Align='Center'>";
strAllUsers += "<Strong>";
strAllUsers += "Users Using this Site";
strAllUsers += "</Strong>";
strAllUsers += "</Td>";
strAllUsers += "</Tr>";
strAllUsers += "<Tr>";
strAllUsers += "<Td bgcolor='#add8e6'>";
strAllUsers += "<Strong>";
strAllUsers += "UserName";
strAllUsers += "</Strong>";
strAllUsers += "</Td>";
strAllUsers += "<Td bgcolor='#add8e6'>";
strAllUsers += "<Strong>";
strAllUsers += "SharePoint Group";
strAllUsers += "</Strong>";
strAllUsers += "</Td>";
strAllUsers += "<Td bgcolor='#add8e6'>";
strAllUsers += "<Strong>";
strAllUsers += "EmailID";
strAllUsers += "</Strong>";
strAllUsers += "</Td>";
strAllUsers += "</Tr>";
strAllUsers += "<Tr>";
strAllUsers += "<Td colspan='3' bgcolor='#add8e6'>";
strAllUsers += "</Td>";
strAllUsers += "</Tr>";
SPWeb currentWeb = SPContext.Current.Web;
foreach (SPGroup grp in currentWeb.Groups)
{
foreach (SPUser user in grp.Users)
{
string strUser = string.Empty;
string strGroup = string.Empty;
string strUserEmail = string.Empty;
strUser = user.Name;
strGroup = grp.Name;
strUserEmail = user.Email;
strAllUsers += "<Tr>";
strAllUsers += "<Td>";
strAllUsers += strUser;
strAllUsers += "</Td>";
strAllUsers += "<Td>";
strAllUsers += strGroup;
strAllUsers += "</Td>";
strAllUsers += "<Td>";
strAllUsers += strUserEmail;
strAllUsers += "</Td>";
strAllUsers += "</Tr>";
strAllUsers += "<Tr>";
strAllUsers += "<Td colspan='3' bgcolor='#add8e6'>";
strAllUsers += "</Td>";
strAllUsers += "</Tr>";
}
}
strAllUsers += "</Table>";
writer.Write(strAllUsers);
});
}
catch (Exception ex)
{
writer.Write(ex.ToString());
}
No comments:
Post a Comment