Create my site programmatically in Sharepoint 2010 - sharepoint-2010

Is it possible to create my site programmatically in SharePoint 2010?
I have added 5 users to AD (Active Directory).
These 5 users are also added in an excel file.
SharePoint 2010 sample site contains a web page where it takes an input as above excel file and on click of a button I want to create 5 my sites of those users specified in excel file with some list, document libraries already created on those my sites.
Is it possible to achieve this functionality in SharePoint 2010? At present I am looking for a code snippet which will use SharePoint 2010 object model and fulfills this requirement.

The UserProfile.CreatePersonalSite method creates a personal site (My Site) for a user.
Various methods and properties of the UserProfile class can then be used to access the site, user's colleagues, quick links, etc.

Related

Show AD User's On SharePoint

I have a requirement to fetch all active directory users data to be added in sharepoint list and show on different pages.
How we can achieve this?
see below to get C# code to do that. Depending upon the sharepoint api (Server object model/CSOM/JSOM) you are using, you would have to take the results from this code to your pages.
How can I get a list of users from active directory?

Prevent VSTO Office Customisation installer prompt from appearing when Opening a document

I have developed a VSTO 4.0 Document Customisation for a custom Template which works fine and installs using ClickOnce.
However, one of the requirements I have is that the resultant documents, being the resultant .docx files, are shared with users outside of my organisation and I DON'T want them to be prompted by VSTO to install the customisation.
The external users should be able to open the document without any VSTO prompts and treat it like a usual Word document, and when the document is saved by the external user and sent back, I can open the document and the the VSTO customisation will work as expected.
This is a usability scenario where a document needs to be collaborated on by my organisation and an external organisation, but I can't expect the external organisation to install the VSTO customisation. They will typically just insert text, pictures and add review comments.
Is there any way that I can achieve this scenario?
BTW, using a Web Addin for Office 365 is not a feasible option at this stage as some of the customisation requirements cannot be achieved with the Word Javascript API.
You need to remove the link from the VSTO document before making it available to outside people. And when the document comes back you can link the customization back to it.
There's an entire MSDN article on the topic, as well as a blog article.
In a nutshell, there are two ways this can be done: from within the opened document or on the closed document.
Run the Document.RemoveCustomization method, which can be assigned to a button in the Ribbon customization, for example. This removes the links stored in Custom Document properties to the VSTO code (which is how the document, itself, finds the code when it opens), as well as any cached data.
Use the ServerDocument.RemoveCustomization method, which essentially does the same thing.
ServerDocument.RemoveCustomization(documentPath);
Re-attaching can only be done via ServerDocument.AddCustomization, logically enough.
string deployManifestPath = System.Environment.GetFolderPath(
Environment.SpecialFolder.Desktop)
+ #"\Publish\WordDocument1.vsto";
Uri deploymentManifestUri = new Uri(deployManifestPath);
ServerDocument.AddCustomization(documentPath, deploymentManifestUri);

Open SharePoint 2010 list item via custom web part

On my SharePoint 2010 site I have a list of items (Document Library). This library contains xml files.
Also, I have a Visual Web Part which displays data from these xml files.
Is there a way to somehow bind the web part to this document library so that the items will be opened via the web part?
Note:
At this point the list item has a hyperlink field which points to the web part page and provides the location of xml file as query string. When the link is accessed, the web part gets provided xml data and parses it as it should.
The problem with this approach is that an absolute url is saved in item's field, which will result into problems when server is changed.
Thank You!
Look into the Sharepoint 2010 "Related List" feature. Sharepoint 2010 allows to send and receive data between webparts, so even your custom webpart.
See the following link for a how-to: SP 2010: How To - Relational lists in SharePoint 2010

sharepoint 2010 document library ip filtering

I need to set up IP filtering in a SharePoint document library based on a group that a user is a member of. More specifically, we have groups set up for each of our customers. Each group should have an allowed IP address attached to it. When a user accesses this document library, we then need to ensure that the user is coming from the IP address attached to their customer group. The IP filtering would only apply to a single document library, not the entire site.
My only idea so far is to create a webpart that checks the user's IP address and redirects if it isn't correct. Then I could put that webpart at the top of a webpart page, and display the document library webpart below that. That's a little hokey, so I was hoping someone had a better idea.
The problem with your proposed solution of a webpart on the AllItems.aspx page is that there multiple ways to get to a document and this would not prevent someone with a direct URL from accessing the document.
You want to take advantage of SharePoint's permission structure. If the documents can be grouped by security, then you could create one library per customer (or one folder within a single library) and set the permissions based on your SharePoint groups for the library/folder. That may not work for you if you need to have one document that is available to multiple groups.
Another option is to set the library security to be restricted to only one system account. Then you could write a webpart (or application page) that checked the user's IP address and using RunWithElevatedPermissions you could get the contents of the libary that are applicable to that user. That would solve the issue of a direct link because they would have to go through your page to access the documents.

SharePoint Web Part to View List from Different SharePoint Site

I am working on SharePoint 2010 instance. I want to be able to view list content in the SharePoint site that this list doesn't belong to. My site does not even share the same site collection as the one containing the list. Is this possible without the custom SharePoint solution coding? Thanks.
Here is a workaround:
http://sp2010.pathtosharepoint.com/SharePoint-User-Toolkit/Pages/Cross-Site-List-Snapshot.aspx
This will work across site collections, as long as the source and target pages are in the same domain. It'll work fine if your only purpose is to display the content, not use the context menus.
Other solutions like Data View Web Part or Content Query Web Part won't work across site collections.