Thursday, 20 February 2014

SharePoint’s hidden User Information List

Browsing the User Information List
The User Information List can be accessed (Only if you’re admin) via the browser by navigating to /_catalogs/users/simple.aspx or  /_catalogs/users/detail.aspx from your site. Ex:http://testthepulse/_catalogs/users/simple.aspx or http://testthepulse/_catalogs/users/detail.aspx
Write code to interact with the User Information List
If you want to interact with this list to set properties on a user (Probably only want to do this if you’re running WSS) you could do it like this:
// Instantiates the User Information List SPList userInformationList = SPContext.Current.Web.SiteUserInfoList; 
// Get the current user SPUser user = SPContext.Current.Web.EnsureUser(@"ZIMMERTobiasZimmergren");
// The actual User Information is within this SPListItem SPListItem userItem = userInformationList.Items.GetItemById(user.ID);
The above code will give you the SPListItem object which links to the currently logged in user (the one executing the request).
You can then work with the SPListItem object like normal to get or set the properties like this:
string pictureURL = userItem["Picture"].ToString();
User Information List Fields
Instead of writing out all the fields/columns availible, you can simply create a new Console Application and insert the following code in order to output all the fields names and internalnames:
 
 1a.png

 
 
You can write a PowerShell script(named ListWebUserInformationListItems.ps1) as following:
 
# Run with SharePoint 2010 Management Shell
$webUrl = Read-Host "Enter the web url"
$web = Get-SPWeb $webUrl
$list = $web.Lists["User Information List"]
$query = New-Object Microsoft.SharePoint.SPQuery
$queryCamlString = '<Query><OrderBy><FieldRef Name="Title" Ascending="True" /></OrderBy></Query>'
$query.Query = $queryCamlString
$userInformationListItems = $list.GetItems($query)
foreach($userInformationListItem in $userInformationListItems)
{
    echo $userInformationListItem.Title
}
Then execute the script and input the web url when console window display the "Enter the web url" message.
Note: You can use SPQuery the get the User Information List items which are the users in this web application. The users are not all the users in the farm. And if you add a ADGroup to the SharePoint, you will add the only one SharePoint user to user information list(The SharePoint User stand for the ADGroup, the ADUser in the ADGroup will not present to the user information list).
 
 
Get a list of all users that have been synchronized into SharePoint.

# Run with SharePoint 2010 Management Shell
$site = Get-SPSite "your URL"
$context = Get-SPServiceContext $site
$profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context)
$profiles = $profileManager.GetEnumerator()
foreach(($profile in $profiles)
{
    $displayName = $profile.DisplayName
}

source: http://zimmergren.net/technical/sharepoints-hidden-user-list-user-information-list  

SharePoint Application Pool Keeps Stopping

After restarting the virtual machine which hosts our dev server, I am keep recieving this error:
image

looking at the IIS application pools, it seems that the same web application pool is stopped and when I start it, as soon as I refresh the page, it stops again.
there might be other reasons for this issue, but in my case, the application pool identity account is my own domain account. I changed the password about 10 days ago, and looks like restarting the VM, caused this error.
it all solved as soon as I changed the password.
go to the application pool Advanced Setting page, click on Identity and use the same account with the new password.

then start the application pool again and it all works fine.

source: http://technet.microsoft.com/en-us/library/cc263454(v=office.12).aspx

Running Scripts From Within Windows PowerShell

Let’s start with running scripts from within Windows PowerShell itself. (Which, truth be told, is probably the most common way to run Windows PowerShell scripts.) Why do you get weird error messages when you try to run a script? That’s easy. The security settings built into Windows PowerShell include something called the “execution policy;” the execution policy determines how (or if) PowerShell runs scripts. By default, PowerShell’s execution policy is set to Restricted; that means that scripts - including those you write yourself - won’t run. Period.
Note. You can verify the settings for your execution policy by typing the following at the PowerShell command prompt and then pressing ENTER:
Get-ExecutionPolicy

Now, admittedly, this might seem a bit severe. After all, what’s the point of having a scripting environment if you can’t even run scripts with it? But that’s OK. If you don’t like the default execution policy (and you probably won’t) then just go ahead and change it. For example, suppose you want to configure PowerShell to run - without question - any scripts that you write yourself, but to run scripts downloaded from the Internet only if those scripts have been signed by a trusted publisher. In that case, use this command to set your execution policy to RemoteSigned:
Set-ExecutionPolicy RemoteSigned

Alternatively, you can set the execution policy to AllSigned (all scripts, including those you write yourself, must be signed by a trusted publisher) or Unrestricted (all scripts will run, regardless of where they come from and whether or not they’ve been signed).
See? No need to need to panic at all, is there?
Note. Not sure what we mean by “signing scripts?” Then open up PowerShell, type the following, and press ENTER:
Get-Help About_Signing

Or, even better, download our Windows PowerShell Graphical Help File and read the same topic in standard Windows help format.
After you change your execution policy settings it’s possible to run scripts. However, you still might run into problems. For example, suppose you change directories from your Windows PowerShell home directory to C:\Scripts (something you can do by typing cd C:\Scripts). As it turns out, the C:\Scripts folder contains a script named Test.ps1. With that in mind you type the following and the press ENTER:
Test.ps1

And here’s the response you get:
The term 'test.ps1' is not recognized as a cmdlet, function, operable program, or script file. Verify the term and try again.
At line:1 char:7
+ test.ps1 <<<<

We know what you’re thinking: didn’t we just change the execution policy? Yes, we did. However, this has nothing to do with the execution policy. Instead, it has to do with the way that PowerShell handles file paths. In general, you need to type the complete file path in order to run a script. That’s true regardless of your location within the file system. It doesn’t matter if you’re in C:\Scripts; you still need to type the following:
C:\Scripts\Test.ps1

Now, we said “in general” because there are a couple of exceptions to this rule. For example, if the script happens to live in the current directory you can start it up using the .\ notation, like so:
.\Test.ps1

Note. There’s no space between the .\ and the script name.
And while PowerShell won’t search the current directory for scripts it will search all of the folders found in your Windows PATH environment variable. What does that mean? That means that if the folder C:\Scripts is in your path then you can run the script using this command:
Test.ps1

But be careful here. Suppose C:\Scripts is not in your Windows path. However, suppose the folder D:\Archive is in the path, and that folder also contains a script named Test.ps1. If you’re in the C:\Scripts directory and you simply type Test.ps1 and press ENTER, guess which script will run? You got it: PowerShell won’t run the script in C:\Scripts, but it will run the script found in D:\Archive. That’s because D:\Archive is in your path.
Just something to keep in mind.

Note. Just for the heck of it, here’s a command that retrieves your Windows PATH environment variable and displays it in a readable fashion:
$a = $env:path; $a.Split(";")

source: http://technet.microsoft.com/en-us/library/ee176949.aspx

SharePoint Admin account


http://testthepulse/howto/Documents/How%20to%20Change%20the%20SharePoint%20Farm%20account.doc
 Add-SPShellAdmin
This cmdlet does a couple of things. First, it adds our admin account to a database role (SharePoint_Shell_Access) that gives us permission to do things that require changes to the database. It also adds our account to a local group (WSS_ADMIN_WPG) on the SharePoint server to give us permissions to make changes there too. Because of that granularity you have to run Add-SPShellAdmin against every database you want it to change, and on all of your SharePoint servers. To meet the first requirement, and to show off a little, I used Get-SPDatabase to get all the databases in my farm, and then I piped it through Add-SPShellAdmin. It looks something like this:
image
That didn’t go well, did it? Like I said before, Add-SPShellAdmin makes changes to each database’s permissions, so the account you run it as has to have permission to do that. Even though sp_install has the securityadmin role on the SQL server, it doesn’t have permission to change this security. Before you run Add-SPShellAdmin make sure the account running it (in my case sp_install) either is in the db_owner group on each databsae, or is in the sysadmin role in SQL. I added sp_install to the sysadmin role and ran my command again:
image

http://www.toddklindt.com/StopUsingSPFarm 

Find computer name from IP

NSLOOKUP <pcname>
NSLOOKUP <IP>
PING <pcname>
PING -A <IP>
NBTSTAT -A <IP>
IPCONFIG /all
NET view /domain:[domain name]> c:\somefile.txt
Where [domain name] is the name of the domain you want to search and somefile.txt is the name of the file to contain the output. 
This will generate a list of every machine and who is logged in. 

http://www.whatismyip.com/

http://www.myiptest.com/
Access computers by IP addresses, but not by Computer Name
http://social.technet.microsoft.com/Forums/windows/en-US/f82b747e-6711-418b-9b6f-317223daa2dc/access-computers-by-ip-addresses-but-not-by-computer-name 

Register Telerik 2013.2.611.35

Drag & drop these file to ‘windows\assembly’ folder:
Telerik.Web.UI.dll
Telrik.Web.Design.dll 
Add these <SafeControl> entries within the <SafeControls> section in web.config:
 
      <SafeControl Assembly="Telerik.Web.UI, Version=2013.2.611.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4" Namespace="Telerik.Web.UI" TypeName="*" Safe="True" SafeAgainstScript="False" />
      <SafeControl Assembly="Telerik.Web.UI, Version=2013.2.611.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4" Namespace="Telerik.Web.UI.Editor" TypeName="*" Safe="True" SafeAgainstScript="False" />
      <SafeControl Assembly="Telerik.Web.UI, Version=2013.2.611.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4" Namespace="Telerik.Web.UI.Widgets" TypeName="*" Safe="True" SafeAgainstScript="False" />
      <SafeControl Assembly="Telerik.Web.UI, Version=2013.2.611.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4" Namespace="Telerik.Web.Design" TypeName="*" Safe="True" SafeAgainstScript="False" />
 
 
Add the clause below to SharePoint 2010 web.config file:
    <pages>
      <controls>
       .....................
        <add tagPrefix="telerik" namespace="Telerik.Web.UI" assembly="Telerik.Web.UI, Version=2013.2.611.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4" />
       </controls>
    </pages>
 
    <modules runAllManagedModulesForAllRequests="true">
       .....................
      <add name="RadUploadModule" type="Telerik.Web.UI.RadUploadHttpModule, Telerik.Web.UI" preCondition="managedHandler" />
    </modules>
 
 
    <handlers>
       .....................
      <add name="ChartImage.axd_*" path="ChartImage.axd" verb="*" type="Telerik.Web.UI.ChartHttpHandler, Telerik.Web.UI, Culture=neutral, PublicKeyToken=121fae78165ba3d4" preCondition="integratedMode" />
      <add name="Telerik.Web.UI.SpellCheckHandler.axd_*" path="Telerik.Web.UI.SpellCheckHandler.axd" verb="*" type="Telerik.Web.UI.SpellCheckHandler, Telerik.Web.UI, Culture=neutral, PublicKeyToken=121fae78165ba3d4" preCondition="integratedMode" />
      <add name="Telerik.Web.UI.DialogHandler.aspx_*" path="Telerik.Web.UI.DialogHandler.aspx" verb="*" type="Telerik.Web.UI.DialogHandler, Telerik.Web.UI, Culture=neutral, PublicKeyToken=121fae78165ba3d4" preCondition="integratedMode" />
      <add name="Telerik.RadUploadProgressHandler.ashx_*" path="Telerik.RadUploadProgressHandler.ashx" verb="*" type="Telerik.Web.UI.Upload.RadUploadProgressHandler, Telerik.Web.UI" preCondition="integratedMode" />
      <add name="Telerik.Web.UI.WebResource.axd_*" path="Telerik.Web.UI.WebResource.axd" verb="*" type="Telerik.Web.UI.WebResource, Telerik.Web.UI" preCondition="integratedMode" />
 
    </handlers>
   
<httpHandlers>
      <remove verb="*" path="*.asmx" />
       .....................
      <add verb="*" path="Telerik.RadUploadProgressHandler.ashx" type="Telerik.Web.UI.Upload.RadUploadProgressHandler, Telerik.Web.UI" />
      <add verb="*" path="Telerik.Web.UI.DialogHandler.aspx" type="Telerik.Web.UI.DialogHandler, Telerik.Web.UI, Culture=neutral, PublicKeyToken=121fae78165ba3d4" />
      <add verb="*" path="Telerik.Web.UI.SpellCheckHandler.axd" type="Telerik.Web.UI.SpellCheckHandler, Telerik.Web.UI, Culture=neutral, PublicKeyToken=121fae78165ba3d4" />
      <add verb="*" path="ChartImage.axd" type="Telerik.Web.UI.ChartHttpHandler, Telerik.Web.UI, Culture=neutral, PublicKeyToken=121fae78165ba3d4" validate="false" />
      <add path="Telerik.Web.UI.WebResource.axd" verb="*" type="Telerik.Web.UI.WebResource, Telerik.Web.UI" validate="false" />
 
    </httpHandlers>
 
    <httpModules>
       .....................
      <add name="RadUploadModule" type="Telerik.Web.UI.RadUploadHttpModule, Telerik.Web.UI" />
    </httpModules>   
 
 
 
 http://yanziyang.wordpress.com/2010/11/01/config-telerik-ajax-in-sharepoint-2010/ 

 

How to fix “Install-SPSolution: Admin SVC must be running in order to create deployment timer job”

To fix the issues, you need to start the SharePoint 2010 Administration service.
1. Go to services control panel.

2. Start the SharePoint 2010 Administration service.

3. Rerun your PowerShell, it should fix the problem. However, you might get another problem “A deployment or retraction is already under way for the solution “*.wsp”, and only one deployment or retraction at a time is supported”, for this problem you can check my other bloghere.

source: http://ybbest.wordpress.com/2011/09/10/how-to-fix-%E2%80%9Cinstall-spsolution-admin-svc-must-be-running-in-order-to-create-deployment-timer-job%E2%80%9D/