Sign in as a Different User in #SharePoint 2013

In SharePoint 2013 you may notice the missing of Sign in as a Different User in the user info menu, this option was helpful for developers for testing purposes or for technical issues helping other users.

There are many tips for solving this problem:

  • You may first run as different user from the browser options by right click + Shift above the browser short cut.



  • You may try to edit in the Welcome.ascx file to add the command to the user menu like below:

open ” C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\CONTROLTEMPLATES\Welcome.ascx” using notepad, and add the following element before the existing “ID_RequestAccess” element:

<SharePoint:MenuItemTemplate runat=”server” ID=”ID_LoginAsDifferentUser”



MenuGroupId=”100″ Sequence=”100″ UseShortId=”true” />



You can now open your SharePoint site and see the result like below:


  • Another way is to write a custom Web Part and add a Link Button Control and write down the following code for redirecting to different user login:



Now after deploying the solution you can add the web part within your site’s default page



Posted in SharePoint General | Leave a comment

Fixing: “The terminal server has exceeded the maximum number of allowed connections”

In a real development environment you may face the problem of multiple server connection “the terminal server has exceeded the maximum number of allowed connections”, which mean that many users actually have login, some of them are active and others may forgot to logoff before leaving the remote server, there are many solutions to this problem, you may login directly to the server if it was in-place and force disconnecting the inactive users, or use the below solution:

(We are going to create a batch file for wide of use for any server)

Open notepad and add the below lines:



Echo force opening remote site


@SET /P RemoteIP=Please Enter Remote Server IP address:

@SET RemoteIP=%RemoteIP%

mstsc /v:%RemoteIP% /admin




Echo Remote Server IP IS: [ %RemoteIP% ]




Then click File > Save as…. and type the name of the file as “remote Server.bat “, don’t forget to choose from Save as Type in the opened dialogue “All files (*.*)” option.

Now you can see your batch, and you can open it and write down the server IP address, it will open the remote server console, and login using your user as normal, then open the remote server Task Manager, hit the “Users” tab, now you can see who is disconnected and occupy the server, now you can right click and force logging him of.



Posted in SharePoint General | Leave a comment

#SharePoint: Restoring content DB

One of the annoying issues in SharePoint is working with DB problems;

one of these problems is restoring content DB, to solve this problem follow the below steps:

  • First you should take backup normally the way you want
  • If accidently crash happened in DB, try to restore the content DB the normal way
  • You will not be abled because there is error (can’t restore database because it’s in use)
  • My simple solution is to take this DB Offline first from both SharePoint Central Administration, and from SQL Server, then make your normal restoration.

Good luck

Posted in SharePoint General | Leave a comment

Integrating Microsoft #SharePoint Server With Oracle Virtual Directory

In many organizations that are considering deploying Microsoft SharePoint they face a

challenge of needing to leverage identities stored in either multiple Active Directory

servers or identities stored in non-LDAP stores.

Oracle Virtual Directory provides a solution to this challenge.

This is because Oracle Virtual Directory enables organizations to aggregate

identity information without needing to consolidate.

The benefits of Oracle Virtual Directory:

• Provides single point of truth for identity-enabled applications

• Clients can access OVD via LDAP, Web Services and SQL

• OVD can connect to data from a variety of sources including LDAP, relational

databases and Web Services

The benefits of SharePoint and Oracle Virtual Directory Integration are:

• Allow a single SharePoint instance to use multiple Active Directory domains

• Allow SharePoint to use identity information stored in non-Active Directory based

identity stores including databases

• Allow SharePoint to use identity information that is split between Active Directory and

non-Active Directory data stores including databases

Example use cases enabled by Oracle Virtual Directory with SharePoint:

• Allow a SharePoint workspace to be used by two different business units who each

maintain their own AD domain

• Allow users to authenticate to SharePoint with Windows credentials but control access

based on job codes maintained in a HR database

Process Overview

The integration process is very similar to any typical OVD deployment. What this package

provides items that can be used for a typical deployment to reduce the time needed to deploy an

OVD-SharePoint solution.

The process steps are:

• Install SharePoint and Oracle Virtual Directory

• Configure OVD to connect to identity stores

• Configure SharePoint’s LDAP provider to connect to OVD

OVD Configuration

• Create a Local Store Adapter (LSA) to store the static base tree value (for example


• Populate the LSA with the static entry data

• Add adapters with ROOT values configured to be branches under the base tree (such as


• For any AD LDAP adapters — add the ObjectClass mapper plug-in and map the cn attribute

to the samaccountname attribute. This is because SharePoint will attempt to lookup the

username in the cn attribute instead of the AD standard samaccountname attribute.

• If using OVD to connect SharePoint to OID – the Proxied Page Size parameter needs to be

set to 10.

Microsoft SharePoint Configuration

The integration with Oracle Virtual Directory requires a version of SharePoint that works with

the SharePoint LDAP Membership provider. This provider is developed and supported by


Create a new zone in SharePoint for the web application (portal) that’s is going to use OVD.

Use the option “Extend an existing Web Application”

• Change the authentication method for the application and choose Forms Authentication

(Applications->Authentication Providers->New Zone). Make sure you use

LdapMembership for Membership Provider and LdapRole for Role Management. These

are the names used in the web.config below.

• Modify the web.config file for the web application in the new zone and also for the Central

Administration site. Add the following entries:

• Between the key <PeoplePickerWildcards> on both files



<add key=”LdapMembership” value=”*” />

<add key=”LdapRole” value=”*” />



• Between the key <system.web> on the Web Application web.config. Replace OVDHOST,


Restart the Application


<membership defaultProvider=”LdapMembership”>


<add server=”OVDHOST” port=”OVDPORT” useSSL=”false”

userDNAttribute=”distinguishedName” userNameAttribute=”cn”

userContainer=”USERSEARCHBASE” userObjectClass=”person”

userFilter=”(ObjectClass=person)” scope=”Subtree”

otherRequiredUserAttributes=”sn,givenname,cn” name=”LdapMembership”

type=”Microsoft.Office.Server.Security.LDAPMembershipProvider, Microsoft.Office.Server,

Version=, Culture=neutral, PublicKeyToken=71E9BCE111E9429C” />



<roleManager defaultProvider=”LdapRole” enabled=”true” cacheRolesInCookie=”false”



<add name=”LdapRole” type=”Microsoft.Office.Server.Security.LDAPRoleProvider,

Microsoft.Office.Server, Version=, Culture=neutral,

PublicKeyToken=71E9BCE111E9429C” server=”OVDHOST” port=”OVDPORT” useSSL=”false”

groupContainer=”GROUPSEARCHBASE” groupNameAttribute=”cn”

groupMemberAttribute=”Member” userNameAttribute=”cn” dnAttribute=”distinguishedname”

groupFilter=”(ObjectClass=group)” scope=”Subtree” />




• Restart the Applications (iisreset)

• Assign a new administrator to the new App/Zone. (Application Management->Policy for

Web Applications->Choose app and new zone). Choose a user as the admin. Users should

show up as {ldapmembership:user id}. If users or groups can’t be searched something is bad

in the web.config file.

• Try to login to the Web App in the new zone, it should ask for credentials with a Form.

• Permissions can be added to users and groups in SharePoint as normally.

Posted in SharePoint General | 1 Comment

RSS Feeds For #SharePoint Site using CQWP

One of the amazing features of using Content Query Web Part (CQWP) is feeding, I have faced an unknown problem with RSS service in my SharePoint 2007 site, though the service was activated within the Central Administration, it couldn’t be found in my web application, i have searched a lot till i found a suggestion of using CQWP to preview the feeds for specific site, here you are the link i found:

and BTW it’s applicable for both SharePoint 2007 & 2010 too.

Posted in SharePoint General | Leave a comment

#SharePoint 2010 Installation failure “Couldn’t find file c:\Windows\System32\drivers\etc\hosts”

Sometimes while you are removing SharePoint 2010 server from your machine and re-install it  , and run the SharePoint 2010 products configuration wizard in the 4th step you may face ,this error “Couldn’t find file c:\Windows\System32\drivers\etc\hosts” or even couldn’t access it, the reason i think is that “hosts” file which path is in “c:\Windows\System32\drivers\etc\” may be deleted or modified, during removing your SharePoint installation by the SharePoint timer service, So     what we shall do is re-creating this file again?

i’m not going to discuss the function of this file you can found it by “Google” it :).

step-1: go to the following path:”c:\Windows\System32\drivers\etc\”, and create a new text file, and insert the following text inside it:

# Copyright (c) 1993-2008 Microsoft Corp.
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
# For example:
#          # source server
#              # x client host       localhost

This is a typical content though the only important part is this line ”   localhost”.

step-2 Save this file as hosts but remove the .txt extension

Now the last step is  to apply appropriate permissions for WSS_Admin_WPG to it.  If you don’t, you are just going to encounter another error (This time a permission error: Access to the path ‘C:\WINDOWS\system32\drivers\etc\HOSTS’ is denied). 

To do so, just right click the hosts file and select properties then,  security tab, then edit, then Add..,then  type WSS_Admin_WPG and click check names and ok, don’t forget to allow modify option like below:

Now re-run the SharePoint 2010 products configuration wizard again and i hope that your installation successfully complete .

Posted in SharePoint General | 2 Comments

Adding a FileUpload component to #SharePoint webpart

Sometimes you need a regular submitting forms for your internet SharePoint site, which deals with customers or visitors to your site.

As a very simple module in your forms, you may need a FileUpload component to upload visitors files to a specific document library location, so here you are a simple peace of code to do so:
//trying uploading file to SharePoint Image Library
protected void UploadFile()
// this is a must be added so as to  supply a delegate that runs a subset of code in the.. //context of an account with higher privileges than the current user.


//fuImageUpload is our fileupload component
if (fuImageUpload.PostedFile != null)

//this checks that the component contains file

if(fuImageUpload.PostedFile.ContentLength > 0)
//converting the file to an array of bytes and read it by input stream

System.IO.Stream strm = fuImageUpload.PostedFile.InputStream;

byte[] byt = new byte[Convert.ToInt32 (fuImageUpload.PostedFile.ContentLength)];

strm.Read(byt, 0, Convert.ToInt32(fuImageUpload.PostedFile.ContentLength));

// Open site where document library is created.
using (SPSite objSite = new SPSite(“your SharePoint site”))
using (SPWeb objWeb = objSite.OpenWeb())
SPFolder mylibrary = objWeb.Folders[“the name of your document library”];

// Set AllowUnsafeUpdates = true to avoid security error

objWeb.AllowUnsafeUpdates = true;

mylibrary.Files.Add(System.IO.Path.GetFileName(fuImageUpload.PostedFile.FileName), byt);



you can use this method inside your webpart to upload any kind of files, enjoy.

Posted in SharePoint General | Leave a comment