Posts tonen met het label SharePoint WebServices. Alle posts tonen
Posts tonen met het label SharePoint WebServices. Alle posts tonen

maandag 7 januari 2013

List of available Sharepoint Services

List of available Sharepoint Services
SharePoint Object Model is a .Net based Application Programming Interface to interact with SharePoint components. But all the applications written using SharePoint Object Model require to be run on the SharePoint Server itself. It is not possible to use it to work remotely with a SharePoint Server.

SharePoint Web Services provides the capability to work with SharePoint server remotely. But SharePoint Web Services are not as much as rich as SharePoint Object Model and all SharePoint features and components are not accessible through Web Services. But it includes Web Services to interact with most commonly used SharePoint features and components. If out-of-the-box SharePoint Web Services doesn’t fit on our requirements, we can also build custom web service on top of SharePoint leveraging the SharePoint Object Model API.
I had prepared a concise list of SharePoint Web Services for my own reference which I am sharing with you:  

1) Administration Web Service (http://<site>/_vti_bin/Admin.asmx): The Administration Web service provides methods that can beused to manage Windows SharePoint Services such as creating or deleting site collections. 
Following are the main methods provided by this service:
  • CreateSite
  • DeleteSite
  • GetLanguages
  • RefreshConfigCache
2) Alerts Web Service (http://<Site>/_vti_bin/Alerts.asmx):
The alerts web service provides methods for working with alert subscriptions
for the listitems in a SharePoint site remotely. Alert subscriptions specify when and how notifications are sent to users when changes are made to content stored on the server. Following are the two main methods provided by this service:
  • GetAlerts
  • DeleteAlerts
3) Copy Web Service (http://<Site>/_vti_bin/Copy.asmx):

This web service provides capability to move files from one list to another within a SharePoint site or between different SharePoint sites. Following are the main methods provided by this service:

  • GetItem
  • CopyIntoItems
  • CopyIntoItemsLocal
4) Document Workspace Web Service (http://<Site>/_vti_bin/Dws.asmx):

This web service provides methods for managing Document Workspace sites and the data they contain. Following are the main methods provided by this service:

a) Managing Document Workspace sites

  • CanCreateDwsUrl
  • CreateDws
  • RenameDws
  • DeleteDws
b) Managing data for the Document Workspace site

  • GetDwsData
  • GetDwsMetaData
  • UpdateDwsData
c) Managing folders in the Document Workspace site

  • CreateFolder
  • DeleteFolder
d) Managing documents in the Document Workspace site

  • FindDwsDoc
e) Managing site users for the Document Workspace site

  • RemoveDwsUser

5) Forms Web Service (http://<Site>/_vti_bin/Forms.asmx):

The Forms service provides methods for returning forms that are used in the user interface when working with the contents of a list. There are following two methods available:

  • GetForm 
  • GetFormCollection
6) Imaging Web Service (http://<Site>/_vti_bin/Imaging.asmx):

The Imaging service provides methods that enable you to create and manage picture libraries. There are following methods that can be utilized with the imaging web service:

  • CheckSubwebAndList
  • CreateNewFolder
  • Delete
  • Download
  • Edit
  • GetItemsByIds
  • GetItemsXMLData
  • GetListItems
  • ListPictureLibrary
  • Rename
  • Upload 

7) Lists Web Service (http://<site>/_vti_bin/Lists.asmx):

The Lists Web service provides methods for working with SharePoint lists, content types, list items, and files. There are following methods that can be utilized with the Lists web service:

  • AddAttachment
  • AddDiscussionBoardItem
  • AddList
  • AddListFromFeature
  • ApplyContentTypeToList
  • CheckInFile
  • CheckOutFile
  • CreateContentType
  • DeleteAttachment
  • DeleteContentType
  • DeleteContentTypeXmlDocument
  • DeleteList
  • GetAttachmentCollection
  • GetList
  • GetListAndView
  • GetListCollection
  • GetListContentType
  • GetListContentTypes
  • GetListItemChanges
  • GetListItemChangesSinceToken
  • GetListItems
  • GetVersionCollection
  • UndoCheckOut
  • UpdateContentType
  • UpdateContentTypeXmlDocument
  • UpdateList
  • UpdateListItems

8) Meetings Web Service (http://<Site>/_vti_bin/Meetings.asmx):

This web service enables you to create and manage Meeting Workspace sites. Following are the main methods available in the web service:

  • AddMeeting
  • AddMeetingFromICal
  • CreateWorkspace
  • DeleteWorkspace
  • GetMeetingWorkspaces
  • GetMeetingsInformation
  • RemoveMeeting
  • RestoreMeeting
  • SetAttendeeResponse
  • SetWorkspaceTitle
  • UpdateMeeting
  • UpdateMeetingFromICal

9) People Web Service (http://<Site>/_vti_bin/People.asmx):

This service provides methods that can be used to associate user identifiers (IDs) with security groups for SharePoint Web site permissions. It contains following methods:

  • GetPrincipalsInGroup
  • ResolvePrincipals
  • SearchPrincipals

10) Permissions Web Service (http://<site>/_vti_bin/Permissions.asmx):

Permissions Web service provides methods for working with SharePoint list and site permissions. Following are the various methods available in this service:

  • AddPermission
  • AddPermissionCollection
  • GetListItemPermissionsByUser
  • GetListPermissionsByUser
  • GetPermissionCollection
  • GetPermissionsByToken
  • GetPermissionsByUser
  • RemovePermission
  • RemovePermissionCollection
  • UpdatePermission

11) SharePoint Directory Management Service (http://<Site>/_vti_bin/sharepointemailws.asmx):

This service provides methods for managing Active Directory e-mail distribution groups and their membership. It provides following main methods:

  • CreateContact
  • DeleteContact
  • ModifyContact
  • CreateDistributionGroup
  • DeleteDistributionGroup
  • ModifyDistributionGroup
  • RenameDistributionGroup
  • ChangeContactsMembershipInDistributionGroup
  • ChangeUsersMembershipInDistributionGroup 

12) Site Data Web Service (http://<Site>/_vti_bin/SiteData.asmx):

The Site Data service provides methods that return metadata or list data from sites or lists in Microsoft Windows SharePoint Services. This web service is read only. Following are the main methods provided by this service:

  • GetList
  • GetListCollection
  • GetListItems 
  • EnumerateFolder
  • GetAttachments
  • GetChanges
  • GetContent
  • GetSite
  • GetWeb 
  • GetSiteAndWeb
  • GetSiteUrl
  • GetURLSegments 

13) Sites Web Service (http://<Site>/_vti_bin/Sites.asmx):

The Sites service provides a method for returning information about the collection of site templates on the virtual server. Following are the main methods provided by this service:

  • ExportWeb
  • ImportWeb
  • GetSiteTemplates
  • GetUpdatedFormDigest

14) Search Web Service (http://<site>/_vti_bin/search.asmx):

The QueryService can be used to query the search indexes in the same way that you would search from the home page of a SharePoint site. Main methods available in this service are as below:

  • Query
  • QueryEx
  • GetPortalSearchInfo
  • GetSearchMetadata
  • Registration
  • Status 

15) Users and Groups Web Service (http://<Site>/_vti_bin/usergroup.asmx):

The Users and Groups Web service provides methods for working with users, role definitions, and groups. It provides huge number of methods which are listed below:

  • AddGroup
  • AddGroupToRole
  • AddRole
  • AddRoleDef
  • AddUserCollectionToGroup
  • AddUserCollectionToRole
  • AddUserToGroup
  • AddUserToRole
  • GenerateXmlMappings 
  • GetAllUserCollectionFromWeb
  • GetGroupCollection
  • GetGroupCollectionFromRole
  • GetGroupCollectionFromSite
  • GetGroupCollectionFromUser
  • GetGroupCollectionFromWeb
  • GetGroupInfo
  • GetHashCode 
  • GetLifetimeService 
  • GetRoleCollection
  • GetRoleCollectionFromGroup
  • GetRoleCollectionFromUser
  • GetRoleCollectionFromWeb
  • GetRoleInfo
  • GetRolesAndPermissionsForCurrentUser
  • GetRolesAndPermissionsForSite
  • GetUserCollection
  • GetUserCollectionFromGroup
  • GetUserCollectionFromRole
  • GetUserCollectionFromSite
  • GetUserCollectionFromWeb
  • GetUserInfo
  • GetUserLoginFromEmail
  • RemoveGroup
  • RemoveGroupFromRole
  • RemoveRole
  • RemoveUserCollectionFromGroup
  • RemoveUserCollectionFromRole
  • RemoveUserCollectionFromSite
  • RemoveUserFromGroup
  • RemoveUserFromRole
  • RemoveUserFromSite
  • RemoveUserFromWeb
  • UpdateGroupInfo
  • UpdateRoleDefInfo
  • UpdateRoleInfo
  • UpdateUserInfo 

16) Versions Web Service (http://<site>/_vti_bin/Versions.asmx):

Versions Web service provides methods for working with file versions in SharePoint document libraries. Methods included in this service:

  • DeleteAllVersions 
  • DeleteVersion 
  • GetVersions 
  • RestoreVersion 

17) Views Web Service (http://<site>/_vti_bin/Views.asmx):

Views Web service provides methods for creating, deleting, or updating list views. Methods included in this service are as below:

  • AddView
  • DeleteView
  • GetView 
  • GetViewCollection 
  • GetViewHtml 
  • UpdateView 
  • UpdateViewHtml

18) Web Part Pages Web Service (http://<Site>/_vti_bin/WebPartPages.asmx):

Web Part Pages service provides methods for working with Web Parts. Following are the various methods provided by this service:

  • AddWebPart
  • AddWebPartToZone
  • AssociateWorkflowMarkup
  • ConvertWebPartFormat
  • DeleteWebPart
  • ExecuteProxyUpdates
  • FetchLegalWorkflowActions
  • GetCustomControlList
  • GetDataFromDataSourceControl
  • GetFormCapabilityFromDataSourceControl
  • GetWebPart
  • GetWebPart2
  • GetWebPartCrossPageCompatibility
  • GetWebPartPage
  • GetWebPartPageConnectionInfo
  • GetWebPartPageDocument
  • GetWebPartProperties
  • GetWebPartProperties2
  • GetXmlDataFromDataSource
  • RemoveWorkflowAssociation
  • RenderWebPartForEdit
  • SaveWebPart
  • SaveWebPart2
  • ValidateWorkflowMarkupAndCreateSupportObjects 

19) Webs Web Service (http://<Site>/_vti_bin/Webs.asmx):

Webs service provides methods for working with sites and subsites. Following are the various methods provided by this service:

  • CreateContentType
  • CustomizeCss
  • DeleteContentType
  • GetActivatedFeatures
  • GetAllSubWebCollection
  • GetColumns
  • GetContentType
  • GetContentTypes
  • GetCustomizedPageStatus
  • GetListTemplates
  • GetWeb
  • GetWebCollection
  • RemoveContentTypeXmlDocument
  • RevertAllFileContentStreams
  • RevertCss
  • RevertFileContentStream
  • UpdateColumns
  • UpdateContentType
  • UpdateContentTypeXmlDocument
  • WebUrlFromPageUrl 

To get the full details of above SharePoint Web Services and their respective Methods please visit SharePoint Web Services MSDN Page @ http://msdn.microsoft.com/en-us/library/ms479390.aspx.

 

 



Visit the Sharepoint Community site for all Sharepoint related info.

Belfius Bank

dinsdag 4 september 2012

Change ContentType and Metadata of your Documents uploaded in a Sharepoint Library


This part for updating a sharepoint contentType for a uploaded Document in a SharePoint Library.
So Once you have uploaded a File into a SharePoint Library, you needs it's ID for changing the
metadata or contentType of a Document.
So first of all call my function below for getting the ID.

    //Call to the function to get the ID
    string sID = sGetID(sSiteUrl, sSiteList, sFileName);
    private string sGetID(string sURL, string sListName, string sFileName) 
    {
        string sID = "";
        SPListsService.Lists list = new SPListsService.Lists();
        list.Url = sSiteUrl + "/_vti_bin/lists.asmx";
  // I have a common Boolean field for determing if I use the current logged on user or to use a Technical User. 
  // attention !!!! The user must have access to your Sharepoint environment.
        if (bDefaultLogon)
            list.Credentials = System.Net.CredentialCache.DefaultCredentials;
        else
        {
            list.PreAuthenticate = true;
            list.Credentials = new System.Net.NetworkCredential(sTechnicalUser, sTechnicalPw, sTechnicalDomain);
        }
        try
        {
   string rowLimit = "99999";
            XmlDocument xmlDoc = new System.Xml.XmlDocument();
            XmlNode listQuery = xmlDoc.CreateNode(XmlNodeType.Element, "Query", "");
            listQuery.InnerXml = "" + sFileName + "";
            listQuery.InnerXml = listQuery.InnerXml + "\"";
            XmlNode listViewFields = xmlDoc.CreateNode(XmlNodeType.Element, "ViewFields", "");
            listViewFields.InnerXml = "" +
                                      "";
            XmlNode listQueryOptions = xmlDoc.CreateNode(XmlNodeType.Element, "QueryOptions", "");
            listQueryOptions.InnerXml = "";
            XmlNode ndListItems = null;
            Guid g = GetWebID(sSiteUrl); // Function to get the ID of your Web
            ndListItems = list.GetListItems(sSiteList, null, listQuery, listViewFields, rowLimit, listQueryOptions, g.ToString());
            sID = ndListItems.ChildNodes[1].ChildNodes[1].Attributes["ows_ID"].Value;
        }
        catch { }
        finally {
           list.Dispose();
        }
        return sID;
    }    
    /* -- Get the Guid of your List  -- */
    private Guid GetWebID(string webPath)
    {
        SPSiteDataService.SiteData siteDataWS = new SPSiteDataService.SiteData();
        if (bDefaultLogon)
            siteDataWS.Credentials = System.Net.CredentialCache.DefaultCredentials;
        else
        {
            siteDataWS.PreAuthenticate = true;
            siteDataWS.Credentials = new System.Net.NetworkCredential(sTechnicalUser, sTechnicalPw, sDomain);
        }
        SPSiteDataService._sWebMetadata webMetaData;
        SPSiteDataService._sWebWithTime[] arrWebWithTime;
        SPSiteDataService._sListWithTime[] arrListWithTime;
        SPSiteDataService._sFPUrl[] arrUrls;
        string roles; string[] roleUsers; string[] roleGroups;
        siteDataWS.Url = webPath + "/_vti_bin/sitedata.asmx";
        uint i = siteDataWS.GetWeb(out webMetaData, out arrWebWithTime, out arrListWithTime, out arrUrls, out roles, out roleUsers, out roleGroups);
        Guid g = new Guid(webMetaData.WebID);
        return g;
    }
 
 


My Code below will change the ContentType of your Document and also some extra Metadata. 
Now it is posible that you would not want to change the ContentType,
 so if not, put the call in comment.
The reason why you need the change of your ContentType and 
the rest of your Metadata in a different XML update block
is because by changing the ContentType, other Columns/MetaData becomes at your position, 
as examle your colums that you have created in your ContentType 
are not at your position before you have changed your ContentType. 
Only the default Columns are available.


    // Call to the function for update file metadate
 bool ret = UpdateFileDataViaBatch(sID, sSiteUrl, sSiteList, Array_FileMetaData);   

 /* --  Update File columns in Sharepoint List-- */
    private Boolean UpdateFileDataViaBatch(string sId, string sSiteUrl, string sSiteList, DataTable ExtraFileMetaData)
    {
        Boolean retcode = true;
        XmlDocument xmlDoc = new XmlDocument();
        XmlElement elBatch = xmlDoc.CreateElement("Batch");
        elBatch.SetAttribute("OnError", "Continue");
        elBatch.SetAttribute("ViewName", GetViewId(sSiteUrl, sSiteList, ""));
        try
        {
            string strBatch = "";
            int id = 0;
            if (ExtraFileMetaData.Rows.Count > 0)
            {
                DataRow drFileInfo = ExtraFileMetaData.Rows[0];
    // call for creating your xml-element for changing the contentType... If you don't need to change it, put it in comment
                strBatch = changeContentType(id,drFileInfo,  sId);
    // call for creating you xml-element for updating your document with extra info.
                strBatch = strBatch + createXmlUpdateBatch(++id, drFileInfo, sId);
            }
            elBatch.InnerXml = strBatch;
            Boolean retcodeUpdSPList = UpdateSPList(sSiteUrl, sSiteList, elBatch);
        }
        catch { }
        return retcode;
    }

    private string changeContentType(int id, DataRow drFileInfo, string sID)
    {
        String strBatch = "";
        strBatch = strBatch + "";
        strBatch = strBatch + "" + sID + "";
        strBatch = strBatch + "" + replaceSpecialChars(drFileInfo["ContentType"].ToString()) + "";
        strBatch = strBatch + "";
        return strBatch;
    }
    private string createXmlUpdateBatch(int id,  DataRow drFileInfo, string sID)
    {
        String strBatch = "";
        strBatch = strBatch + "";
        strBatch = strBatch + "" + sID + "";
        strBatch = strBatch + "" + replaceSpecialChars(drFileInfo["ExtraFileMetaData1"].ToString()) + "";
        strBatch = strBatch + "" + replaceSpecialChars(drFileInfo["ExtraFileMetaData2"].ToString()) + "";
        strBatch = strBatch + "";
        return strBatch;
    }

    private string replaceSpecialChars(string mystring)
    {
        mystring = mystring.Replace("&", "&");
        mystring = mystring.Replace("<", "<");
        mystring = mystring.Replace(">", ">");
        mystring = mystring.Replace("\"", """);
        mystring = mystring.Replace("'", "'");
        return mystring;
    }

 
 

At least you also need the function for the real update... 
otherwise you have your batch XML document, 
but your data isn't updated yet.
So you also need my function below for executing your 
Batch Element by using the Lists.asmx webservice.


 /* -- Update SharePoint List -- */
    private Boolean UpdateSPList(string sSiteUrl, string sSiteList, XmlElement elBatch)
    {
        Boolean retcode = true;
        SPListsService.Lists list = new SPListsService.Lists();
        list.Url = sSiteUrl + "/_vti_bin/lists.asmx";
        if (bDefaultLogon)
            list.Credentials = System.Net.CredentialCache.DefaultCredentials;
        else
        {
            list.PreAuthenticate = true;
            list.Credentials = new System.Net.NetworkCredential(sTechnicalUser, sTechnicalPw, sDomain);
        }
        try
        {
            XmlNode ndReturn = list.UpdateListItems(sSiteList, elBatch);
            // Instantiate a new XML document object to hold the return value(s) 
            XmlDocument xmlResult = new XmlDocument();
            xmlResult.LoadXml(ndReturn.OuterXml);
            // SharePoint XML always uses a fixed namespace; you'll need your own NamespaceManager object to parse the return values 
            XmlNamespaceManager nsMgr = new XmlNamespaceManager(xmlResult.NameTable);
            nsMgr.AddNamespace("sp", ndReturn.NamespaceURI);
            XmlNode ndRoot = xmlResult.SelectSingleNode("sp:Results", nsMgr);
            // Find the ErrorCode node, which exists for all operations regardless of status. 
            XmlNodeList nlResults = ndRoot.SelectNodes("//sp:Result/sp:ErrorCode", nsMgr);
            // Loop through the node collection and find each ErrorCode entry 
            foreach (XmlNode ndResult in nlResults)
            {
                // Check the value of the node to determine its status 
                if (ndResult.InnerText != "0x00000000")
                {
                    XmlNode ndError = ndResult.NextSibling;
                    string sError = ndError.InnerText;
                    // Set the value of string variable to hold the error code 
                    // If you want to trip the Try…Catch, throw and exception of whatever type suits you 
                }
                else
                {
                    // put your code on success... whatever you want 
                }
            }
        }
        catch (Exception e)
        {
            retcode = false;
        }
        finally
        {
            list.Dispose();
        }
        return retcode;
    }
 
 
 

If you have questions, don't hesitate to contact me... 
I only use the webservices to be undependent of the environment
to run the code on... So it hasn't to be on a sharepoint Environment !
If there are problems with my code, please let me know... 

Upload File from a networkdrive into a Sharepoint Library


Last week I wrote some code for migrating a networkdrive folder content into a SharePoint Library. 
You cannot use the Lists.asmx for uploading the documents because this webservice does not provide
the functionality for uploading files. 
But after a little bit of research I found quickly that you can use the copy.asmx webservice. 
Normally it is used for copying files between two SharePoint Libraries but it also 
work for copying files from a networkdrive into a SharePoint Library.

So you can use the code behind for copying a file on a network drive in a Sharepoint Library.



        SPCopyService.Copy copy = new SPCopyService.Copy();
  copy.Url = sSiteUrl + "/_vti_bin/copy.asmx";
        try
        {
            if (bDefaultLogon)
                copy.Credentials = System.Net.CredentialCache.DefaultCredentials;
            else
            {
                copy.PreAuthenticate = true;
                copy.Credentials = new System.Net.NetworkCredential(sTechnicalUserID, sTechnicalUserPW, sTechnicalUserDomain);
            }

            string destinationUrl = sSharePointDestinationFolder + "/" + sfilename;
            // destinationUrl = SiteUrl + "/" + SiteLibrary + "/" + OptionalFolder + "/" + filename.Extention
            string[] destinationUrls = { destinationUrl };
            SPCopyService.FieldInformation info1 = new SPCopyService.FieldInformation();
            info1.DisplayName = sfilename;
            info1.InternalName = replaceSpecialChars(sfilename);
            info1.Type = SPCopyService.FieldType.Text;
            info1.Value = replaceSpecialChars(sfilename);
            SPCopyService.FieldInformation[] info = { info1 };
            SPCopyService.CopyResult copyResult = new SPCopyService.CopyResult();
            SPCopyService.CopyResult[] copyResults = { copyResult };
            //Reading the document contents in to stream
            FileStream strm = new FileStream(sFilePath + @"\" + sfilename, FileMode.Open, FileAccess.Read);
            byte[] fileContents = new Byte[strm.Length];
            byte[] r = new Byte[strm.Length];
            int ia = strm.Read(fileContents, 0, Convert.ToInt32(strm.Length));
            strm.Close();
            // call the webservice procedure CopyIntoItems       
            uint result = copy.CopyIntoItems(sfilename, destinationUrls, info, fileContents, out copyResults);
            // Check for Errors:     
            foreach (SPCopyService.CopyResult copyRes in copyResults)
            {
                string msg =  "====================================" +
                "\n " + "SharePoint Error:" +
                "\n " + "              Url: " + copyRes.DestinationUrl +
                "\n " + "              Error Code: " + copyRes.ErrorCode +
                "\n " + "              Message: " + copyRes.ErrorMessage +
                "\n " + "====================================";
                if (copyRes.ErrorCode.ToString().Equals("Success"))
                {
                    // code for success if needed...
                }
                else
                {
                    // code for a failure if needed...
                }
                Console.WriteLine(msg);
            }
        }
        catch (Exception e)
        {
            iFailedUpdatedRecords++;
            Console.WriteLine("   Error on upload...");
        }
        finally {
            copy.Dispose();
        }
 

 

maandag 9 april 2012

Update or Insert Sharepoint ListItems in a List Library


Looking for a way to update a Sharepoint ListItem by using the Lists.asmx webservice...
For doing this you need to create your function to create your Xml Layout
and afterwards call the function below UpdateSPList.
 

 XmlDocument xmlDoc = new XmlDocument();
 XmlElement elBatch = xmlDoc.CreateElement("Batch");
 elBatch.SetAttribute("OnError", "Continue");
 // this because if one of the methods gives an error it will continue with the next method
 elBatch.SetAttribute("ViewName", Sharepoint_ViewId);
 elBatch.InnerXml = strBatch;
 
 returncode = UpdateSPList( sSiteUrl,  sSiteList,  elBatch);


 
strBatch containing for example:
        
<Method ID='0' Cmd='Update'>
    <Field Name='ID'> SharepointListItem.ows_ID </Field>
</Method>
<Method ID='1' Cmd='Update'>
    <Field Name='ID'>OtherSharepointListItem.ows_ID </Field>
</Method>
<Method ID='0' Cmd='New'>
            <Field Name='ID'>New</Field>
            <Field Name='Title'>YOUR TEXT HERE</Field>
</Method>
<Method ID='1' Cmd='New'>
            <Field Name='ID'>New</Field>
            <Field Name='Title'>YOUR TEXT HERE</Field>

 



Remark: The next Chars must be translated in the text values for your Fieldtag:
    "&" ==> "&"
    "<" ==> "<"
    ">" ==> ">"
    "\"" ==> """
    "'" ==> "'"

Below you find my Function that I have created that actualy does 
the update or insert into your List.
It requires three parameters : 
- the Site Url you are working on
- the List name on which you want to add or update one or more items
- the XML that contains the Batch Element

You will see that the function also uses the next global parameters
- sTechnicalUser
- sTechnicalPw
- sDomain
- bDefaultLogon (if true you will connect to the webservice with the 
user that is executing the program, otherwise use the technical user with it's
password and domain.  
This is done for giving the possibility to let shedule the program. 
         
 private Boolean UpdateSPList(string sSiteUrl, string sSiteList, XmlElement elBatch)
        {
            Boolean retcode = true;

            REFERANCENAME.Lists list = new REFERANCENAME.Lists();
            list.Url = sSiteUrl + "/_vti_bin/lists.asmx";
            if (bDefaultLogon)
                list.Credentials = System.Net.CredentialCache.DefaultCredentials;
            else
            {
                list.PreAuthenticate = true;
                list.Credentials = new System.Net.NetworkCredential(sTechnicalUser, sTechnicalPw, sDomain);
            }
            logThis("Start updateSPList " + sSiteUrl + " " + sSiteList + " ...");
            try
            {
                XmlNode ndReturn = list.UpdateListItems(sSiteList, elBatch);
                logThis(sSpaces + "return " + ndReturn.OuterXml);
                // Instantiate a new XML document object to hold the return value(s)
                XmlDocument xmlResult = new XmlDocument();
                xmlResult.LoadXml(ndReturn.OuterXml);
                // SharePoint XML always uses a fixed namespace; you'll need your own NamespaceManager object to parse the return values
                XmlNamespaceManager nsMgr = new XmlNamespaceManager(xmlResult.NameTable);
                nsMgr.AddNamespace("sp", ndReturn.NamespaceURI);
                XmlNode ndRoot = xmlResult.SelectSingleNode("sp:Results", nsMgr);
                // Find the ErrorCode node, which exists for all operations regardless of status.
                XmlNodeList nlResults = ndRoot.SelectNodes("//sp:Result/sp:ErrorCode", nsMgr);
                // Loop through the node collection and find each ErrorCode entry
                foreach (XmlNode ndResult in nlResults)
                {
                    // Check the value of the node to determine its status
                    if (ndResult.InnerText != "0x00000000")
                    {
                        XmlNode ndError = ndResult.NextSibling;
                        string sError = ndError.InnerText;
                        // Set the value of string variable to hold the error code
                        this.logThis("Update operation failed for " + sSiteList + ": " + sError + ".");
                        // If you want to trip the Try…Catch, throw and exception of whatever type suits you
                        iFailedUpdatedRecords++;
                    }
                    else
                    {
                        iUpdatedRecords++;
                    }
                }
           }
            catch (Exception e)
            {
                logThis(sSpaces + "Error UpdateSPList ", e);
                retcode = false;
            }
            finally
            {
                list.Dispose(); // important!!!! always dispose your sharepoint objects !!!!!
                logThis("End updateSPList " + sSiteUrl + " " + sSiteList);
            }
            return retcode;
        }
 


dinsdag 15 november 2011

How to update a Hyperlink column


Today I had a little problem for updating a Hyperlink Column by using the List.asmx web service. 
I wanted to insert a New item with a Hyperlink Column but not only by giving the URL. 
So I searched how to add the description to the Column. 
Quickly found that you can use a comma to indicate the URL in the first part 
and the description in the second part. 

But as you know Sharepoint you must follow certain rules that where not 
descripted in the SharePoint Documentation.

So if you need to do the same, keep in mind next rules...

For updating or inserting a Hyperlink value in a Sharepoint list using the List.asmx web services,
make sure to follow these guidelines:
- Notice that URL needs to include “http://” e.g. http://www.google.com/
- If you want to specify a description, 
  make sure to include a space between the comma (,) and the description.  

So our URL field value needs to have ,,
e.g. http://www.google.com/, Google.

batch example:
<Batch OnError=\”Continue\”> 
 <Method ID=\”1\” Cmd=\”New\”> 
     <Field Name=\”URL\”>http://www.google.com, Google</Field> 
    </Method> 
</Batch>
 

woensdag 9 november 2011

How to Add a Windows SharePoint Web Service Reference


You can add a Web reference to each SharePoint Web service
through your Visual Studio .NET IDE. In your Solution Explorer, 
right-click on your project and select "Add Web Reference"
from your popup menu.
The table below shows the URLs to use for each Web service provided by WSS.
Enter the URL to the Web service and click the Go button.
This will show you a summary of all available Web methods in the dialog box.
Next, enter the name of the Web reference and then click Add Reference.
WSS Web Services Web Reference
Administration Service http://[server-url:port-number]/_vti_adm/admin.asmx
Alerts Service http://[server-url]/_vti_bin/alerts.asmx
Document Workspace Service http://[server-url]/_vti_bin/dws.asmx
Forms Service http://[server-url]/_vti_bin/forms.asmx
Imaging Service http://[server-url]/_vti_bin/imaging.asmx
List Data Retrieval Service http://[server-url]/_vti_bin/dspsts.asmx
Lists Service http://[server-url]/_vti_bin/lists.asmx
Meetings Service http://[server-url]/_vti_bin/meetings.asmx
Permissions Service http://[server-url]/_vti_bin/permissions.asmx
Site Data Service http://[server-url]/_vti_bin/sitedata.asmx
Site Service http://[server-url]/_vti_bin/sites.asmx
Users and Groups Service http://[server-url]/_vti_bin/usergroup.asmx
Versions Service http://[server-url]/_vti_bin/versions.asmx
Views Service http://[server-url]/_vti_bin/views.asmx
Web Part Pages Service http://[server-url]/_vti_bin/webpartpages.asmx
Webs Service http://[server-url]/_vti_bin/webs.asmx

zaterdag 5 november 2011

Get ListItems using SharePoint Services


Get ListItems with there columns of a specific SharePoint List 
using the SharePoint Webservice Lists.asmx .  

    private XmlNode GetSiteListItems(string sSiteUrl, string sSiteList)
    {
        WS_Lists.Lists list = new WS_Lists.Lists();
        list.Url = sSiteUrl + "/_vti_bin/lists.asmx";
        if (bDefaultLogon)
            list.Credentials = System.Net.CredentialCache.DefaultCredentials;
        else
        {
            list.PreAuthenticate = true;
            list.Credentials = new System.Net.NetworkCredential(sTechnicalUser, sTechnicalPw, sDomain);
        }
        Console.WriteLine(sSpaces + "Start GetSiteListItems " + sSiteList + " " + sSiteList + "...");
        string rowLimit = "99999";
        XmlDocument xmlDoc = new System.Xml.XmlDocument();
        XmlNode listQuery = xmlDoc.CreateNode(XmlNodeType.Element, "Query", "");
        XmlNode listViewFields = xmlDoc.CreateNode(XmlNodeType.Element, "ViewFields", "");
        listViewFields.InnerXml = "<FieldRef Name=\"Title\">" +
                                  "<FieldRef Name=\"INTERNAL_FIELDNAME1\"></FieldRef>" + 
                                  "<FieldRef Name=\"INTERNAL_FIELDNAME2\"></FieldRef>" +
                                  "<FieldRef Name=\"INTERNAL_FIELDNAME3\"></FieldRef>" +
                                  "<FieldRef Name=\"INTERNAL_FIELDNAME4\"></FieldRef>" +
                                  "<FieldRef Name=\"INTERNAL_FIELDNAME5\"></FieldRef>" +
                                  "<FieldRef Name=\"INTERNAL_FIELDNAME6\"></FieldRef>" ;
          
        XmlNode listQueryOptions = xmlDoc.CreateNode(XmlNodeType.Element, "QueryOptions", "");
        XmlNode ndListItems = null;
        try
        {
            ndListItems = list.GetListItems(sSiteList, null, listQuery, listViewFields, rowLimit, listQueryOptions, null);
        }
        catch (Exception e)
        {
            Console.WriteLine(sSpaces + "Error GetSiteListItems {0}", e.Message);
        }
        finally
        {
            list.Dispose();
            Console.WriteLine(sSpaces + "End GetSiteListItems " + sSiteList + " " + sSiteList);
        }
         return ndListItems;
    }

 

Apply a SiteCollection ContentType on a List of a Site or SubSite


Apply a SiteCollection ContentType on a List using the SharePoint Webservice Lists.asmx .  

    private Boolean ApplyContentTypeOnList(string myUrl, string myList, string myContentTypeId)
    {
        Boolean retCode = true;
        SetStatus("Initialize webservice...");
        WS_Lists.Lists lists = new WS_Lists.Lists();
        if (chk_DefaultLoggin.Checked)
            lists.Credentials = System.Net.CredentialCache.DefaultCredentials;
        else
        {
            lists.PreAuthenticate = true;
            lists.Credentials = new System.Net.NetworkCredential(txt_UserID.Text, txt_PassWord.Text, txt_domain.Text);
        }
        lists.Url = myUrl + @"/_vti_bin/lists.asmx";
        try
        {
            this.SetStatus("Activate contenttypeID " + myContentTypeId +" on list " + myList);
            if (TMSI_Trace_On.Checked)
                this.traceThis("Apply contentType to list...");
            XmlNode myNode = lists.ApplyContentTypeToList(myUrl, myContentTypeId, myList);
            if (myNode.OuterXml == "")
            {
                // get ListId for URLLINK
                XmlNode listID = lists.GetList(myList);
                retCode = true;
            }
            else
            {
                retCode = false;
            }
        }
        catch (Exception exception1)
        {
            MessageBox.Show(exception1.Message, "Error on applying contenttype on list", MessageBoxButtons.OK);
            this.SetStatus("Error on applying contenttype on list");
            retCode = false;
        }
        finally
        {
            lists.Dispose();
        }
        return retCode;
    }

 

Get ContentTypes of a List


Get available ContentTypes on a List using the SharePoint Webservice Lists.asmx .  

    private void GetListsContentTypes(string myurl, string mylist, ArrayList myAlist)
    {
        SetStatus("Initialize webservice...");
        myAlist.Clear();
        WS_Lists.Lists lists = new WS_Lists.Lists();
        if (chk_DefaultLoggin.Checked)
            lists.Credentials = System.Net.CredentialCache.DefaultCredentials;
        else
        {
            lists.PreAuthenticate = true;
            lists.Credentials = new System.Net.NetworkCredential(txt_UserID.Text, txt_PassWord.Text, txt_domain.Text);
        }
        lists.Url = myurl + @"/_vti_bin/lists.asmx";
        try
        {
            this.SetStatus("getting contenttypes for list " + mylist);
            XmlNode myNode = lists.GetListContentTypes(mylist, "0x01");
            XmlNodeList nodes = myNode.SelectNodes("*");
            foreach (XmlNode node in nodes)
            {
                myAlist.Add(node.Attributes["Name"].Value);
            }
        }
        catch (Exception exception1)
        {
            MessageBox.Show(exception1.Message, "Error loading list info", MessageBoxButtons.OK);
            this.SetStatus("Error loading list info");
        }
        finally
        {
            lists.Dispose();
        }
    }

 

Clone a View to you new List based on your Template ListView


Clone a view of a template list to your new list
using the SharePoint Webservice Views.asmx .  

    private void CloneViewXML(string mytemplateUrl ,string myurl, string mylist, string myview )
    {
        SetStatus("Initialize webservice...");
        SetStatus("Calling webservice...");
        Boolean retcode = true;
        WS.Views views = new WS.Views();
        if (chk_DefaultLoggin.Checked)
            views.Credentials = System.Net.CredentialCache.DefaultCredentials;
        else
        {
            views.PreAuthenticate = true;
            views.Credentials = new System.Net.NetworkCredential(txt_UserID.Text, txt_PassWord.Text, txt_domain.Text);
        }
        views.Url = mytemplateUrl + @"/_vti_bin/Views.asmx";
        try
        {
            this.SetStatus("getting viewxml for view " + myview + " on list " + mylist );
            XmlNode myListNode = views.GetViewCollection(mylist);
            XmlNodeList lnodes = myListNode.SelectNodes("*");
            String viewGuid = "";
            XmlNode vnQuery = null;
            XmlNode vnFields = null;
            XmlNode vnRowLimit = null;
            foreach (XmlNode lnode in lnodes)
            {
                // ID of the View
                if (lnode.Attributes["DisplayName"].Value == myview)
                    viewGuid = lnode.Attributes["Name"].Value;
            }
             /// if no guid found... exit
            if (viewGuid != "")
            {
                XmlNode viewxml = views.GetView(mylist, viewGuid); // internal listname en view guid
                String sViewType = viewxml.Attributes["Type"].Value;
                XmlNodeList nodes = viewxml.SelectNodes("*");
                foreach (XmlNode node in nodes)
                {
                    if (node.Name == "Query")
                        vnQuery = node;
                    if (node.Name == "ViewFields")
                        vnFields = node;
                    if (node.Name == "RowLimit")
                        vnRowLimit = node;
                }
                if (vnQuery != null && vnFields != null && vnRowLimit != null)
                {
                    if (TMSI_Trace_On.Checked)
                        this.traceThis("Creating view...");
                    // call function to create the new view...
                    retcode = CreateView(myurl, mylist, myview, sViewType, vnQuery, vnFields, vnRowLimit, false);
                    if (!retcode)
                    {
                        this.SetStatus("creation of view failed....");
                    }
                    else
                    {
                        this.SetStatus("view created");
                    }
                }
            }
            else
            {
                this.SetStatus("Error on finding template view guid");
                retcode = false;
            }
            this.SetStatus("");
        }
        catch (Exception exception1)
        {
            MessageBox.Show(exception1.Message, "Error loading view info", MessageBoxButtons.OK);
            this.SetStatus("Error loading view info");
            retcode = false;
        }
        finally
        {
            views.Dispose();
        }
    }

    private Boolean CreateView(String myUrl, String myList, String myView, String myViewType, XmlNode myQuery, XmlNode myFields, XmlNode myRowLimit, Boolean myDefaultView)
    {
        Boolean retcode = true;
        SetStatus("Initialize webservice...");
        WS_Views.Views views = new WS_Views.Views();
        if (chk_DefaultLoggin.Checked)
            views.Credentials = System.Net.CredentialCache.DefaultCredentials;
        else
        {
            views.PreAuthenticate = true;
            views.Credentials = new System.Net.NetworkCredential(txt_UserID.Text, txt_PassWord.Text, txt_domain.Text);
        }
        views.Url = myUrl + @"/_vti_bin/Views.asmx";
        try
        {
            XmlNode retnode = views.AddView(myList, myView, myFields, myQuery, myRowLimit, myViewType, myDefaultView);
            SetStatus("View " + myUrl + myList + myView + "created..");
        }
        catch (Exception exeption1)
        {
            this.SetStatus("Error on Create View" + exeption1.Message);
            retcode = false;
        }
        finally
        {
            views.Dispose();
        }
        return retcode;
    }
 

Get all Views defined on a List


In this function fill's in a ArrayList with the list of Views defined on a Site
using the SharePoint Webservice Views.asmx .  

    private void GetNewListsViews(string myurl, string mylist, ArrayList myAlist)
    {
        SetStatus("Initialize webservice...");
        myAlist.Clear();
        WS_Views.Views views = new WS_Views.Views();
        if (chk_DefaultLoggin.Checked)
            views.Credentials = System.Net.CredentialCache.DefaultCredentials;
        else
        {
            views.PreAuthenticate = true;
            views.Credentials = new System.Net.NetworkCredential(txt_UserID.Text, txt_PassWord.Text, txt_domain.Text);
        }
        views.Url = myurl + @"/_vti_bin/Views.asmx";
        try
        {
            this.SetStatus("getting views for list " + mylist);
            XmlNode myNode = views.GetViewCollection(mylist);
            XmlNodeList nodes = myNode.SelectNodes("*");
            foreach (XmlNode node in nodes)
            {
                if (node.Attributes["DisplayName"].Value != "")
                    myAlist.Add(node.Attributes["DisplayName"].Value);
            }
        }
        catch (Exception exception1)
        {
            MessageBox.Show(exception1.Message, "Error loading list info", MessageBoxButtons.OK);
            this.SetStatus("Error loading list info");
        }
        finally
        {
            views.Dispose();
        }
    }

 

Get Permissions info of a List or a Site


In this function fill's in a ArrayList with the some permission properties of 
users or usergroups of a Site or a List using the SharePoint Webservice Lists.asmx .  

    private void GetSPPermissions(string myurl, string mylist, string stype, ArrayList myAlist)
    {
        SetStatus("Initialize webservice...");
        myAlist.Clear();
        WS_Permissions.Permissions permissions = new WS_Permissions.Permissions();
        if (chk_DefaultLoggin.Checked)
            permissions.Credentials = System.Net.CredentialCache.DefaultCredentials;
        else
        {
            permissions.PreAuthenticate = true;
            permissions.Credentials = new System.Net.NetworkCredential(txt_UserID.Text, txt_PassWord.Text, txt_domain.Text);
        }
        permissions.Url = myurl + @"/_vti_bin/permissions.asmx";
        try
        {
   // stype can contain Web or List depending if mylist contains a listname or a sitename
            XmlNode myNode = permissions.GetPermissionCollection(mylist, stype);
            XmlNodeList pnodes = myNode.SelectNodes("*");
            foreach (XmlNode pnode in pnodes)
            {
                foreach (XmlNode node in pnode)
                {
                    ArrayList userList = new ArrayList();
                    string mId = node.Attributes["MemberID"].Value;
                    string mMask = node.Attributes["Mask"].Value;
                    string mIsUser = node.Attributes["MemberIsUser"].Value;
                    
                    string mRoleName = "";
                    string mUserLogin = "";
                    if (mIsUser.ToLower().Equals("true"))
                    {
                        mUserLogin = node.Attributes["UserLogin"].Value;
                    }
                    else
                    {
                        mRoleName = node.Attributes["GroupName"].Value;
                    }
                    string mGlobal = node.Attributes["MemberGlobal"].Value;
                    string mName = "";
                    if (mIsUser.Equals("False"))
                        mName = mRoleName;
                    else
                        mName = mUserLogin;
                    userList.Add(mName);
                    userList.Add(mIsUser);
                    userList.Add(mRoleName);
                    userList.Add(mGlobal);
                    myAlist.Add(userList);
                }
            }
        }
        catch (Exception exception1)
        {
            MessageBox.Show(exception1.Message, "Error loading Permissions info", MessageBoxButtons.OK);
            this.SetStatus("Error loading Permissions info");
         }
        finally
        {
            permissions.Dispose();
        }
    }

 

Get available Lists on a Site


In this function fill's in an ArrayList with all available Lists on a Site using the SharePoint 
Webservice Lists.asmx .  
Little remark, a document library is also a list and will also be returned by the webservice.

   private void GetLists(string myurl, ArrayList myAList)
    {
        SetStatus("Initialize webservice...");
        myAList.Clear();
        WS_Lists.Lists lists = new WS_Lists.Lists();
         if (chk_DefaultLoggin.Checked)
            lists.Credentials = System.Net.CredentialCache.DefaultCredentials;
        else
        {
            lists.PreAuthenticate = true;
            lists.Credentials = new System.Net.NetworkCredential(txt_UserID.Text, txt_PassWord.Text, txt_domain.Text);
        }
        lists.Url = myurl + @"/_vti_bin/lists.asmx";
        try
        {
            this.SetStatus("Getting lists for site " + myurl);
            XmlNode myNode = lists.GetListCollection();
            XmlNodeList nodes = myNode.SelectNodes("*");
            foreach (XmlNode node in nodes)
            {
                myAList.Add(node.Attributes["Title"].Value);
            }
        }
        catch (Exception exception1)
        {
            MessageBox.Show(exception1.Message, "Error loading list info", MessageBoxButtons.OK);
            this.SetStatus("Error loading list info");
        }
        finally
        {
            lists.Dispose();
        }
    }
 

Get all Sites and SubSites of a SiteCollection


In this function you receive a ArrayList containing all Sites/SubSites of a SiteCollection using 
the SharePoint Webservice Webs.asmx .  

    private ArrayList GetSites(string siteurl)
    {
        SetStatus("Initialize webservice...");
        ArrayList myList = null;
        // reading al the sites and subsites via webservice
        WS_Webs.Webs webs = new WS_Webs.Webs();
        if (chk_DefaultLoggin.Checked)
            webs.Credentials = System.Net.CredentialCache.DefaultCredentials;
        else
        {
            webs.PreAuthenticate = true;
            webs.Credentials = new System.Net.NetworkCredential(txt_UserID.Text, txt_PassWord.Text, txt_domain.Text);
        }
        webs.Url = siteurl + @"/_vti_bin/webs.asmx";
        try
        {
             XmlNode myNode = webs.GetAllSubWebCollection();
            XmlNodeList nodes = myNode.SelectNodes("*");
            foreach (XmlNode node in nodes)
            {
                // only add sites that starts with the given site url
                if ( node.Attributes["Url"].Value.StartsWith(siteurl))
                    myList.Add(node.Attributes["Url"].Value);
            }
        }
        catch (Exception exception1)
        {
            MessageBox.Show(exception1.Message, "Error loading siteinfo", MessageBoxButtons.OK);
            this.SetStatus("Error loading site info");
        }
        finally
        {
            webs.Dispose();  
        }
    }

 

Get Site description


In this function you receive the description of a Site using the SharePoint 
Webservice Webs.asmx .  

    private string GetSiteDescription(string siteurl)
    {
        SetStatus("Initialize webservice...");
        string siteDesc = "";
         // reading al the sites and subsites via webservice
        WS_Webs.Webs webs = new WS_Webs.Webs();
        if (chk_DefaultLoggin.Checked)
            webs.Credentials = System.Net.CredentialCache.DefaultCredentials;
        else
        {
            webs.PreAuthenticate = true;
            webs.Credentials = new System.Net.NetworkCredential(txt_UserID.Text, txt_PassWord.Text, txt_domain.Text);
        }
        webs.Url = siteurl + @"/_vti_bin/webs.asmx";
        try
        {
             XmlNode myNode = webs.GetWeb(siteurl);
            if (myNode != null)
            {
                siteDesc = myNode.Attributes["Description"].Value;
            }
        }
        catch (Exception exception1)
        {
            MessageBox.Show(exception1.Message, "Error loading SiteName", MessageBoxButtons.OK);
            this.SetStatus("Error loading site Name info");
        }
        finally
        {
            webs.Dispose();
        }
        return siteDesc;
    }

 

Get the name of a Site


In this function you receive the Name of a Site based on the Site Url, this using the SharePoint 
Webservice Webs.asmx  

    private string GetSiteName(string siteurl)
    {
        SetStatus("Initialize webservice...");
        string siteName = "";
        // reading al the sites and subsites via webservice
        WS_Webs.Webs webs = new WS_Webs.Webs();
        if (chk_DefaultLoggin.Checked)
            webs.Credentials = System.Net.CredentialCache.DefaultCredentials;
        else
        {
            webs.PreAuthenticate = true;
            webs.Credentials = new System.Net.NetworkCredential(txt_UserID.Text, txt_PassWord.Text, txt_domain.Text);
        }
        webs.Url = siteurl + @"/_vti_bin/webs.asmx";
        try
        {
            XmlNode myNode = webs.GetWeb(siteurl);
            if (myNode != null)
            {
                // only add sites that starts with the given site url
                siteName = myNode.Attributes["Title"].Value;
            }
        }
        catch (Exception exception1)
        {
            MessageBox.Show(exception1.Message, "Error loading SiteName", MessageBoxButtons.OK);
            this.SetStatus("Error loading site Name info");
        }
        finally
        {
            webs.Dispose();
        }
        return siteName;
     }

 

How to get the list of users defined in a SharePoint Group


This is an example of how you can receive the users of a SharePoint Group using the SharePoint 
Webservice UserGroup.asmx and put the result in a ArrayList.  

private void GetUserOfGroup(string myurl,string sUGroup, ArrayList myAlist)
    {
        SetStatus("Initialize webservice...");
        WS_UserGroup.UserGroup usergroup = new WS_UserGroup.UserGroup();
        if (chk_DefaultLoggin.Checked)
            usergroup.Credentials = System.Net.CredentialCache.DefaultCredentials;
        else
        {
            usergroup.PreAuthenticate = true;
            usergroup.Credentials = new System.Net.NetworkCredential(txt_UserID.Text, txt_PassWord.Text, txt_domain.Text);
        }
        usergroup.Url = myurl + @"/_vti_bin/usergroup.asmx";

        try
        {
            this.SetStatus("Getting Users for group " + sUGroup);
            XmlNode myNode = usergroup.GetUserCollectionFromGroup(sUGroup);
            XmlNodeList unodes = myNode.SelectNodes("*");
            foreach (XmlNode pnode in unodes)
            {
                foreach (XmlNode node in pnode)
                {
                    ArrayList mAList = new ArrayList();
                    string mName = node.Attributes["Name"].Value;
                    string mLoginName = node.Attributes["LoginName"].Value;
                    string mEmail = node.Attributes["Email"].Value;
                    string mSiteAdmin = node.Attributes["IsSiteAdmin"].Value;
                    string mDomainGroup = node.Attributes["IsDomainGroup"].Value;
                    mAList.Add(sUGroup);
                    mAList.Add(mName);
                    mAList.Add(mLoginName);
                    mAList.Add(mEmail);
                    mAList.Add(mSiteAdmin);
                    mAList.Add(mDomainGroup);
         myAlist.Add(mAList);
                }
            }

        }
        catch (Exception exception1)
        {
            MessageBox.Show(exception1.Message, "Error loading GetUsersOfGroup ", MessageBoxButtons.OK);
            this.SetStatus("Error loading GetUsersOfGroup ");
        }
        finally
        {
            usergroup.Dispose();
        }
        this.SetStatus("");
    }