Hi all,
I have Sharepoint 2003. I downloaded the WSS SDK and tried to run the first example code in my asp.net app.:
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.Utilities;
SPSite mySite = SPControl.GetContextSite(Context);
SPWebCollection allSites = mySite.AllWebs;
foreach (SPWeb subSite in allSites)
{
string listGroups = "";
SPUserCollection allUsers = subSite.Users;
foreach (SPUser user in allUsers)
{
if (user.LoginName == TextBox1.Text)
{
SPRoleCollection allGroups = user.Roles;
foreach (SPRole group in allGroups)
{
listGroups += SPEncode.HtmlEncode(group.Name) + " ";
}
userList += subSite.ServerRelativeUrl.ToString() + "<BR>";
}
}
}
I get error in the "foreach" statement, when the debugger steps to the "allSites" word.
The error is: "Input string was not in a correct format".
I have set reference to Microsoft.Sharepoint.DLL & am using .Net 2.0.
What could be going wrong ? Any pointers ?
TIA,
Sheila
I have Sharepoint 2003. I downloaded the WSS SDK and tried to run the first example code in my asp.net app.:
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.Utilities;
SPSite mySite = SPControl.GetContextSite(Context);
SPWebCollection allSites = mySite.AllWebs;
foreach (SPWeb subSite in allSites)
{
string listGroups = "";
SPUserCollection allUsers = subSite.Users;
foreach (SPUser user in allUsers)
{
if (user.LoginName == TextBox1.Text)
{
SPRoleCollection allGroups = user.Roles;
foreach (SPRole group in allGroups)
{
listGroups += SPEncode.HtmlEncode(group.Name) + " ";
}
userList += subSite.ServerRelativeUrl.ToString() + "<BR>";
}
}
}
I get error in the "foreach" statement, when the debugger steps to the "allSites" word.
The error is: "Input string was not in a correct format".
I have set reference to Microsoft.Sharepoint.DLL & am using .Net 2.0.
What could be going wrong ? Any pointers ?
TIA,
Sheila