Posts

Showing posts from April, 2011

SPWeb Property Bag

The following url explains about SPWeb Property bag and how to add properties to the SPWeb Properties.  http://trentacular.com/2009/06/sharepoint-the-wicked-spwebproperties-propertybag/ Hierarchical Object Store (SPPersistedObject) Provides the methods for an object to automatically serialize its state, persist that state in a permanent store, retrieve it at a later time, and deserialize it back into an in-memory object. http://www.chaholl.com/archive/2011/01/30/the-skinny-on-sppersistedobject-and-the-hierarchical-object-store-in.aspx http://www.chaholl.com/archive/2010/12/13/persisting-a-stream-to-the-sharepoint-configuration-database.aspx

Create DefaultSharepoint Groups

I am recently trying to create site collection using Admin Web Service. When site creating using admin web service, share point not creating default share point groups. You have to write custom code to create share point default groups. The following is the code to create default sp groups. public bool CreateDefaultSPGroups( string url)     {         bool isGroupsCreated = false ;         try         {             using ( SPSite site = new SPSite (url))             {                 using ( SPWeb web = site.OpenWeb())                 {                     web.CreateDefaultAssociatedGroups(site.Owner.LoginName, site.SecondaryContact.LoginName, string .Empty);                     isGroupsCreated = true ;                 }             }         }         catch ( Exception ex)         {             isGroupsCreated = false ;   }         return isGroupsCreated;     }

RunPowershellCommand From ASPx Page

private void RunPowershellCommand( string loginName)     {         try         {             PSSnapInException exc = new PSSnapInException ();             RunspaceConfiguration rc = RunspaceConfiguration .Create();             PSSnapInInfo info = rc.AddPSSnapIn( "Microsoft.Sharepoint.Powershell" , out exc);             Runspace rs = RunspaceFactory .CreateRunspace(rc);             rs.Open();             Pipeline cmd = rs.CreatePipeline( string .Format( "set-SPSite -Identity http://sitecollection -SecondaryOwnerAlias {0}" ,loginName));                          Collection < PSObject > results = cmd.Invoke();             foreach ( PSObject str in results)                   SendToTextFile(str.ToString());           }         catch ( Exception ex)         {             SendToTextFile( "RunPowershellCommand() Error: " + ex.ToString());           }     }