Sunday, December 2, 2007

Programming in Moss 2007 object Model

The names microsoft put are distinctive and catchy....thats why microsoft developers never seem to pull their hair in remembering the name of the last software they used and found it good.

The MOSS 2007 or Microsoft Office Sharepoint Server 2007 is the rechristened version of the SharePoint Server 2003. It has got a majority of features that made 2003 a nightmare for developers and UI developers.

The MOSS2007 creates and arranges data in the form of Lists or so called libraries (although this may be just a beginner description) .
The Heirarchy follows as under

Site
Web
ListItemCollection
List Item
FieldCollection
Field.

Such a classification makes the understanding and development using MOSS Object Model easier.

The following piece of code will Loop through the List of users of a particular web site on MOSS and return the datatable of data regarding its users.


public DataTable getListOfUsers(string siteUrl)
{
SPSite myCollections = new SPSite(siteUrl);
DataTable odtSiteUsers = new DataTable();
foreach (SPWeb site in myCollections.AllWebs)
{
SPUserCollection oSPUser = site.SiteUsers;
if (site.Name == "SharepointBuzzRajiv")
{
DataRow drUserRow;
odtSiteUsers.Columns.Add(new DataColumn("UserName", typeof(string)));
odtSiteUsers.Columns.Add(new DataColumn("Email", typeof(string)));
odtSiteUsers.Columns.Add(new DataColumn("isSiteAdmin", typeof(string)));
foreach (SPUser oUser in oSPUser)
{
drUserRow = odtSiteUsers.NewRow();
drUserRow[0] = oUser.Name;
drUserRow[1] = oUser.Email;
drUserRow[2] = oUser.IsSiteAdmin.ToString();
odtSiteUsers.Rows.Add(drUserRow);
}
}
}
return odtSiteUsers;
}


I have got much more to blog in detail....but that will follow later on....

No comments: