Why do I get error "The LDAP server is unavailable" while connecting to external domain via sync connection in SharePoint UPSA ?

Hello,
I am trying to connect to external domain via UPS Account having "Replicate Directory changes" permission on external domain while creating sync connection in UPSA.
I have checked below URLS :
http://social.technet.microsoft.com/Forums/en-US/1912bf88-8fec-4b5d-9d1e-a42db8318e33/ldap-server-is-unavailable-sharepoint-2010-user-synchronization?forum=sharepointadminprevious
http://social.technet.microsoft.com/Forums/en-US/6525d3aa-9197-42a2-aea0-190b84ac8356/the-ldap-server-is-unavailable?forum=sharepointadminprevious
And looks like its network connectivity issue - and hence I have verified that port 389 is open by infra team.
Note : I am able to connect to local AD , does it make sense that port is not open for external domain ? 
Can anyone please let me know what can be the issue ? 
Your help will be highly appreciated as I am struggling to fix this issue since  quite long time but no luck yet.
Thank you in advance.
Kind regards,
Dipti Chhatrapati

Hi Dipti,
If you have Two-Way trust relationship then not sure if you have tried below:
Create a folder on the SharePoint server
Go to Folder properties - Security tab
Try adding user of the external domain on the folder
Please let us know if you are able to add the user or not. If you are able to add then it means that the connection and trust is proper and you should be able to create sync connection in UPA without any issues or else there is some issue with the connectivity
or the trust which is configured.
Please also make sure that you have given permissions to sync account as per below TechNet:
http://technet.microsoft.com/en-us/library/hh296982(v=office.15).aspx
Replicate Directory changes permissions are also required on cn=configuration container, below are the steps:
Grant Replicate Directory Changes permission on the cn=configuration container
Use this procedure to grant Replicate Directory Changes permission on the cn=configuration container to an account.
To grant Replicate Directory Changes permission on the cn=configuration container
On the domain controller, click Start, click Run, type adsiedit.msc, and then click OK.
If the Configuration node is not already present, do the following:
In the navigation pane, click ADSI Edit.
On the Action menu, click Connect to.
In the Connection Point area of the Connection Settings dialog box, click Select
a well know Naming Context, select Configuration from the drop-down list, and then click OK.
Expand the Configuration node, right-click the CN=Configuration... node, and then click Properties.
In the Properties dialog box, click the Security tab.
In the Group or user names section, click Add.
Type the name of the synchronization account, and then click OK.
In the Group or user names section, select the synchronization account.
In the Permissions section, select the Allow check box next to the Replicating
Directory Changes (Replicate Directory Changes on Windows Server 2003) permission, and then click OK.
Kind regards,
Bhavik K Jain
Please ensure that you mark a question as Answered once you receive a satisfactory response.

Similar Messages

  • The LDAP server is unavailable after installing KB2868725

    After installing the KB2868725 Windows Update, a strange LDAPs connection problem occur.
    Context : we have a C# web site (.NET 4.0) that perform an LDAPs Bind operation over LDAPs. The web server is not on the same domain (bind operations are perform again multiple LDAPs Server), and the code work like a charm more than a year.
    So after installing the KB2868725 Windows Update we get a “System.DirectoryServices.Protocols.LdapException: The LDAP server is unavailable.” exception from the same application. When we uninstall the update, the error stop.
    The problem is present ONLY over a SECURE connection.
    We have multiple web server in production and every server where the KB2868725 Windows Update is not installed are working perfectly.
    We build a test application with this simple code, work fine on “non-KB2868725 updated server”:
    void BindLDAP()
    LdapDirectoryIdentifier ldi = new LdapDirectoryIdentifier("example.com", 636, true, false);
    LdapConnection ldapCnn = new LdapConnection(ldi, new NetworkCredential("myUsername", "myPassword"), AuthType.Basic);
    ldapCnn.SessionOptions.VerifyServerCertificate = new VerifyServerCertificateCallback(Validate);
    ldapCnn.Bind();
    private static bool Validate(LdapConnection connection, X509Certificate certificate) { return true; }
    Stack trace:
    System.DirectoryServices.Protocols.LdapException: The LDAP server is unavailable.
    at System.DirectoryServices.Protocols.LdapConnection.Connect()
    at System.DirectoryServices.Protocols.LdapConnection.BindHelper(NetworkCredential newCredential, Boolean needSetCredential)
    Server: Windows Server 2008 R2 Standard, Service Pack 1 (64-bit)
    We tried to change every connections settings, change .NET version (2.0, 3.5 and 4.0), build the test application directly on the server and nothing work.
    If we use others LDAP tool (like http://technet.microsoft.com/en-us/sysinternals/bb963907.aspx) the problem also occur : “The server is not operational.”
    Moreover, if we installed these updates the problem also occur: KB2574819, KB2830477, KB2871997, KB2592687.
    We can’t install any Windows Updates, that’s a problem. We would like to find a solution, please help us ;-)

    Hi,
    The server is configure to get the Windows Update from a WSUS server. Those updates are downloaded from Microsoft. 
    I follow these steps:
    1. Uninstall Windows Update : KB2574819, KB2830477 (KB2857650) and KB2913751;
    2. Perform a LDAP connection test : work perfectly;
    3. Install Update KB2574819;
    4. Perform a LDAP connection test : not working (The LDAP server is unavailable.);
    5. Install Update KB2830477 (KB2857650 is include in KB2830477 update);
    6. Perform a LDAP connection test : not working (The LDAP server is unavailable.);
    7. Install Update KB2913751;
    8. Perform a LDAP connection test : not working (The LDAP server is unavailable.);
    The problem here is we can’t install KB2574819, KB2830477 (KB2857650) and KB2913751 on our productions servers because of the connections problems (install process work fine, is the effects of these Windows Updates).
    Philippe Bernier

  • Adding server in DAG failing with error Error: Cluster API failed: "AddClusterNode() (MaxPercentage=25) failed with 0x800706ba. Error: The RPC server is unavailable

    Hi, Below is teh environments
    DC: Win 2008 R2 SP1
    Exchange Server OS: Win  2012  R2 Std 
    Exchange : 2013 SP1 Ent
    Two Servers with CAS+MB role, already part of one DAG. I am trying to add one new server in existing DAG. The installation of exchange 2013 competed successfully. However when i am adding it to the existing DAG, the below error is coming. Please help
    to solve the issue. Thanks in advance.
    A server-side database availability group administrative operation failed with a transient error. Please try the operation again. Error: An error occurred while attempting a cluster operation. Error: Cluster API failed: "AddClusterNode() (MaxPercentage=25)
    failed with 0x800706ba. Error: The RPC server is unavailable" [Server: cluster owner FQDN]
    Manu

    Hi Manu,
    As Deepak mentioned, please try to enable IPv6 on all member servers first.
    Based on my research, In Microsoft Exchange Server 2013, IPv6 is supported only when IPv4 is also installed and enabled. If Exchange 2013 is deployed in this configuration, and the network supports IPv4 and IPv6, all Exchange servers can send data to and
    receive data from devices, servers, and clients that use IPv6 addresses.
    Please also configure or disable Firewall to allow the connection.
    Thanks
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact [email protected]
    Mavis Huang
    TechNet Community Support

  • The RPC server is unavailable while trying to take Remote Desktop of 2003 Server.

    Dear All
    Recently I am facing remote desktop login problem in on Windows 2003 Server.
    While I am enter user name and password server give me logon error.
    "The system cannot log you on due to the following error:
    The RPC server is unavailable.
    Please try again or consult your system administrator.
    Kindly help me.........

    I just started spontaneously having this problem yesterday. I am not aware of anything having changed that would prompt it, though I did do a Windows Update on all servers AFTER the problem manifested to see if that might fix it. (No such luck) For reasons
    unexplained, the system HAS let me in a few times, though it hasn't been consistent, and now it seems to have locked me out entirely (except through the VSphere back door, explained below). I am running Windows 7 on my laptop, and I have received a report
    of the same problem from another employee trying to log in from their computer, which I believe is also running Win7.
    I am running two VMWare instances of Server 2003 R2, one Domain Controller and another production environment. I can RDP just fine to the DC, but not the production. Also, using the VSphere VMware management client on a separate machine, I CAN log in to
    the production environment without a problem.
    I have tried the fixes around restarting stopped services, but nothing has helped yet. I've also tried disabling my anti-virus temporarily, with no effect. I tried pinging the various IP addresses, and received timeouts on the 2 images, as well as their
    host server. Again, though, I CAN log into the DC without issue.
    Could someone please elaborate on how to create this registry key? On which image would I add this key? (I am a novice user, so using regedit is somewhat unfamiliar to me)
    Any other thoughts about potential solutions?
    Thanks!
    Update Dec 15 2011: Just tried restarting the Production image, via VSphere, and then successfully logged in and out 3 times in quick succession by regular RDP. The symptoms have been temporarily soothed, though I wonder if the underlying problem remains?
    Still no answer to why this happened in the first place, so I'd appreciate input.
    Update Dec 16 2011: The problem came back this morning, and remained all day. I can still access by VSphere, but have other users who need to access by regular RDP. I'd rather not have to reboot the system constantly just to allow access... Any help is much
    appreciated!

  • Active Directory Error 0x51 occurred when trying to check the suitability of server ' servername '. Error: 'Active directory response: The LDAP server is unavailable'. It was running the command 'Get-OwaVirtualDirectory'.

    This issue is driving us nuts - there are no issues with Domain Controllers or AD in this environment.  The server it is citing in the error has been retired - it was gracefully dcpromo'ed down and removed from the environment.  DNS has no record of it, nor is it located anywhere else.  We are not able to log into Outlook Web App either with authentication failed errors - and I can't help but expect these 2 issues are related?  I tried hard coding the Configuration Domain Controller at the org level, as well as using the -staticdomaincontrollers and -staticglobalcatalogservers with the "Set-ExchangeServer" powershell command - no luck....  System settings of the exchange 2010 servers show they are pointing to the correct DCs - but I still get this error accompanied with long delays in rendering windows in EMC.  Extremely frustrating.....  I have an issue logged with MS now, but they aren't looking at them until Nov 9.  Has anyone seen this issue at all?  More info on the OWA config - using Form based auth, and I'm not able to perform a simple test-owaconnectivity -mailboxcredential (get-credential\username) -allowuntrustedcertificate -allowinsecurelogon - please help

    Create a "global catalog" on the 2nd domain contoller, will fix this problem. 
    To create a new global catalog:
    On the domain controller where you want the new global catalog, start the Active Directory Sites and Services snap-in. To start the snap-in, click Start , point to Programs , point to Administrative Tools , and then click Active Directory Sites and Services .
    In the console tree, double-click Sites , and then double-click <var>sitename</var> .
    Double-click Servers , click your domain controller, right-click NTDS Settings , and then click Properties .
    On the General tab, click to select the Global catalog check box to assign the role of global catalog to this server.
    Restart the domain controller.

  • Why am I getting error "The deployment cannot use the VirtualNetwork MyProjectVN that belongs to a region."?

    I have a Virtual Network configured in Azure with Site-2-Site VPN, it works fine and connects to our on premise VPN network.
    I have a web role that I would like to deploy into this VN. I have two cloud configurations, DEV and TEST, both are deployed to their own designated cloud service instance.
    Previously, only the DEV configuration was published to the VN, and it worked properly without any problems. However, today I also wanted to publish the TEST environment into the VN, but I get the error message "The deployment cannot use the VirtualNetwork
    MyProjectVN that belongs to a region.".
    What can be the reason for this? I didn't choose any regions when setting up the VN, and both cloud service instances are in the North Europe location.

    Hi Mark,
    Based on my research, I haven't found any related official documents indicate this kind of difference between Staging and Production. Accroding to the error message, you can create a virtual network within an affinity group to see if the issue persists.
    In addition, since it is related to Web roles, you can also ask in the forum below for assistance:
    https://social.msdn.microsoft.com/Forums/en-US/home?forum=windowsazuredevelopment
    Best regards,
    Susie
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected]

  • Why can't I get my Mac to like the LDAP server?

    On Monday I started hammering away at getting the LDAP server setup on the Linux server with openldap. I was able to get a test Mac running Leopard to see the LDAP server and the accounts. The next battle was to get home directories to mount under /home. I was about to do that after finding a working ldif example using automaster and autohome. After that I was able to get the Public share automatically mounted on /Network/Public. Wonderful!
    Tuesday I came in thinking that the next battle would be with Samba. Unfortunately, somewhere in powering off the Mac and rebooting it, I lost all the share mounting! It still sees the accounts, but it absolutely will not see the mounts. In trying to figure it out I have wiped the LDAP database and restarted it, I have wiped the test Mac twice, I have made sure the Mac is running the latest updates, and still nothing.
    If I go into dscl this is now what I see:
    ls Automount/
    Record Name Unknown
    Record Name Unknown
    ls AutomountMap/
    Record Name Unknown
    Record Name Unknown
    cat Mounts/10.110.1.1:\/share\/public/
    dsAttrTypeNative:cn: 10.110.1.1:/share/public
    dsAttrTypeNative:objectClass: mount top
    AppleMetaNodeLocation: /LDAPv3/10.110.1.1
    RecordName: 10.110.1.1:/share/public
    RecordType: dsRecTypeStandard:Mounts
    On the LDAP server, the records look like:
    dn: automountMapName=auto_master,ou=mounts,dc=example,dc=com
    automountMapName: auto_master
    objectClass: top
    objectClass: automountMap
    dn: automountKey=/home,automountMapName=auto_master,ou=mounts,dc=example,dc=com
    objectClass: top
    objectClass: automount
    automountKey: /home
    automountInformation: auto_home
    dn: automountMapName=auto_home,ou=mounts,dc=example,dc=com
    automountMapName: auto_home
    objectClass: top
    objectClass: automountMap
    dn: automountKey=*,automountMapName=auto_home,ou=mounts,dc=example,dc=com
    objectClass: top
    objectClass: automount
    automountKey: *
    automountInformation: 10.110.1.1:/home/&
    dn: cn=10.110.1.1:/share/public,ou=mounts,dc=example,dc=com
    mountDirectory: /Network/Public
    objectClass: mount
    objectClass: top
    mountType: nfs
    cn: 10.110.1.1:/share/public
    It looks like for some reason it's either missing entries from the LDAP server, and/or it's ignoring some of the mapping and leaving them out. The Mounts entry is missing the VFSLinkDir which maps to mountDirectory. The Automount stuff is missing the RecordName which maps to automountKey and automountMapName.
    What the heck happened? Why does the Mac refuse to see the LDAP server the way it did on Monday?

    I am having something similar going on and can't sort out what it is doing:
    ldiffs:
    dn: automountMapName=auto_master,dc=example,dc=edu
    objectClass: top
    objectClass: automountMap
    automountMapName: auto_master
    dn: automountKey=/foo,automountMapName=auto_master,ou=Mounts,dc=soe,dc=ucsc,
    dc=edu
    objectClass: automount
    automountKey: /foo
    automountInformation: auto.foo,dc=example,dc=edu -rw,resvport,
    hard,intr,nosuid,tcp
    Second one:
    dn: automountMapName=auto.foo,dc=example,dc=edu
    objectClass: top
    objectClass: automountMap
    automountMapName: auto.foo
    dn: automountKey=tstaff,automountMapName=auto.foo,dc=example,dc=edu
    objectClass: top
    objectClass: automount
    automountInformation: fileserver:/export/foo/tstaff
    automountKey: tstaff
    9/25/09 11:45:25 AM com.apple.automountd[1101] t0xb0289000 name=tstaff[] map=auto.foo,dc=example,dc=edu opts=rw,resvport,hard,intr,nosuid,tcp path=/foo direct=0
    9/25/09 11:45:25 AM com.apple.automountd[1101] t0xb0289000 getmapent_ds called
    9/25/09 11:45:25 AM com.apple.automountd[1101] t0xb0289000 getmapent_ds: key=[ tstaff ]
    9/25/09 11:45:25 AM com.apple.automountd[1101] t0xb0289000 ds_match called
    9/25/09 11:45:25 AM com.apple.automountd[1101] t0xb0289000 ds_match: key =[ tstaff ]
    9/25/09 11:45:25 AM com.apple.automountd[1101] t0xb0289000 ds_match: Searching for tstaff,automountMapName=auto.foo,dc=example,dc=edu
    9/25/09 11:45:25 AM automountd[1101] ds_search failed
    exiting ...
    It seems like it can't find the trigger point tstaff. It is looking for:
    ds_match: Searching for tstaff,automountMapName=auto.foo,dc=example,dc=edu
    which isn't what the DN is in ldap:
    Distinguished Name: automountKey=tstaff,automountMapName=auto.foo,dc=example,dc=edu
    any thoughts?
    regards,
    Derek

  • I am getting error "The connection to the server was reset while the page was loading" whenever i am trying to view one perticular page asset?.

    Hi Experts,
    i am getting  error "The connection to the server was reset while the page was loading" whenever i am trying to view one perticular page asset. i am directly view page asset through contribute editor. Please tell me what is the issue.
    Thanks
    Satya

    Hello.
    Can you provide more details? Is there more information in the logs (what's the stacktrace)? What version are you working with?
    Regards,
    Raul.

  • Error : Cannot connect to the LDAP server

    I have exported a file called "test1.ldif"
    and then import in a new Oracle ldap server using the command:
    ldapadd -p 389 -D cn="directory manager" -w <password> -f test1.ldif
    But there is error "Cannot connect to the LDAP server".
    Actually, I'm migrating the ldap data from 1 machine to another, please advise. Thanks

    Check your ldap port, by default it is 4032...
    --Bill                                                                                                                                                                                                           

  • An error occurred while contacting the LDAP server.

    An error occurred while contacting the LDAP server.
    (No such object)
    The server could not locate the entry. If adding a new entry, be sure that the parent of the entry you are trying to add exists. If you received this error while searching or viewing an entry, it indicates that the entry which was being searched for does not exist.

    I did the silly thing, i gave Base DN as o=domainname.com,which is supposed to give like dc=domainname, dc=com and restarted the server. LDAP works fine.

  • TS1424 Why am I getting error 11222 when trying to access the store?

    Why am I getting error 11222 when trying to access the store?

    The 11222s can sometimes be associated with LSP issues.
    I'd try the following document:
    Apple software on Windows: May see performance issues and blank iTunes Store
    (If there's a SpeedBit LSP showing up in Autoruns, it's usually best to just uninstall your SpeedBit Video Accelerator.)

  • Why do I get Error: 404 when I try to download a Lightroom upgrade on the UK site?

    Why do I get Error: 404 when I try to download a Lightroom upgrade on the UK site?

    Try downloading from below link :
    New Adobe Lightroom 6 (CC) Direct Download Links – Free Trials | ProDesignTools
    Feel free to post , if you need further assistance

  • TS3694 Why am I getting error code 3194 when i try to restore my ipod?

    Why am I getting error code 3194 when I try to restore my ipod touch 4th generation

    This device is not eligible for the requested build: Also sometimes displayed as an "error 3194." If you receive this alert, update to the latest version of iTunes. Third-party security software or router security settings can also cause this issue. To resolve this, follow Troubleshooting security software issues.
    Downgrading to a previous version of iOS is not supported. If you have installed software to perform unauthorized modifications to your iOS device, that software may have redirected connections to the update server (gs.apple.com) within the Hosts file. First you must uninstall the unauthorized modification software from the computer, then edit out the "gs.apple.com" redirect from the hosts file, and then restart the computer for the host file changes to take affect.  For steps to edit the Hosts file and allow iTunes to communicate with the update server, see iTunes: Troubleshooting iTunes Store on your computer, iPhone, iPad, or iPod—follow steps under the heading Blocked by configuration (Mac OS X / Windows) > Rebuild network information > The hosts file may also be blocking the iTunes Store. If you do not uninstall the unauthorized modification software prior to editing the hosts file, that software may automatically modify the hosts file again on restart. Also, using an older or modified .ipsw file can cause this issue. Try moving the current .ipsw file, or try restoring in a new user to ensure that iTunes downloads a new .ipsw.
    Error 3194: Resolve error 3194 by updating to the latest version of iTunes. "This device is not eligible for the requested build" in the updater logs confirms this is the root of the issue. For more Error 3194 steps see: This device is not eligible for the requested build above.
    http://support.apple.com/kb/TS3694#error3194
    Also see:
    iPhone Error 3194 - How to Fix iTunes Error 3194?

  • I can't get at my LDAP server using JMQ 1.1.  What's wrong?

    I have jmq 1.1 running on solaris. We have recently installed an ldap server on another box to provide access for jndi. I am trying to run the
    jmqconfig program to add topic by issuing the following command ...
    /opt/SUNWjmq/bin/jmqconfig -a -t t -n "cn=myTopic" -o "name=This is my Test Topic" -o "host=apollo" -o "subnet=5" -i "com.s
    un.jndi.ldap.LdapCtxFactory" -u "ldap://e-rewards.com:389/o=dev.e-rewards.com" -s simple -p "uid=devadm, o=dev.e-rewards.co
    m" -c dev999
    I am getting this message...
    Error: You have problems with access control. Please verify that
    your jmqadmin.policy file is setup properly.
    Can you tell me what I need to do to the jmqadmin.policy file to make this work?

    It looks like there is a CommunicationException while trying
    to talk to the LDAP server. Please check the SocketPermission
    entry in the jmqadmin.policy file to ensure network permission
    to the LDAP server host/port is granted. If the jmqadmin.policy
    file looks OK, I'd suggest to try a simple JNDI example which
    talks to the LDAP server to see if communication to the LDAP
    server is fine by using a similar java.security.policy file
    as jmqadmin.policy (please see JMQ 1.1 QuickStart guide chapter
    4 for more information on security policy files).
    Please note that iMQ 2.0 (formerly named JMQ) has been released

  • Provider-hosted Apps debug error: The remote server returned an error: (401) unauthorised

    Hi,
    Any help appreciated!!
    I'm getting this error: "The remote server returned an error: (401) unauthorised when I debug a provider-hosted app.  I get the error on this line:  
    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    See code below
    I created a high trust development environment following the instructions provided here:
    http://msdn.microsoft.com/en-us/library/office/fp179901(v=office.15).aspx and
    http://msdn.microsoft.com/library/office/fp179923
    I created a provider-hosted app with the intent to:
    create a SharePoint list in the appweb
    Use self-signed certificate, tokenhepler.cs and sharepointcontext.cs to retrieve current user context and access on SharePoint.  (No changes were made to tokenhelper.cs and sharepointcontext.cs)
    retrieve list items from the SharePoint list in a button click event handler on a default.aspx of the remote web
    What happens:
    The app is deployed successfully to the Dev site
    The SharePoint feature is deployed and activated
    The default.aspx page of the remote web loads
    The error (see image) is returned on clicking of the button
    My environment is an on-premise SharePoint 2013 with AD and my dev box is standalone windows 8.1 running Visual Studio Professional 2013 Update 3.
    The code block below is a copy of the default.aspx code-behind
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Microsoft.SharePoint.Client;
    using Microsoft.IdentityModel.S2S.Tokens;
    using System.Net;
    using System.IO;
    using System.Xml;
    using System.Data;
    using System.Xml.Linq;
    using System.Xml.XPath;
    namespace Idea.GeneratorWeb
    public partial class Default : System.Web.UI.Page
    SharePointContextToken contextToken;
    string accessToken;
    Uri sharepointUrl;
    protected void Page_PreInit(object sender, EventArgs e)
    Uri redirectUrl;
    switch (SharePointContextProvider.CheckRedirectionStatus(Context, out redirectUrl))
    case RedirectionStatus.Ok:
    return;
    case RedirectionStatus.ShouldRedirect:
    Response.Redirect(redirectUrl.AbsoluteUri, endResponse: true);
    break;
    case RedirectionStatus.CanNotRedirect:
    Response.Write("An error occurred while processing your request.");
    Response.End();
    break;
    protected void Page_Load(object sender, EventArgs e)
    //// The following code gets the client context and Title property by using TokenHelper.
    //// To access other properties, the app may need to request permissions on the host web.
    var spContext = SharePointContextProvider.Current.GetSharePointContext(Context);
    //var spContext = new ClientContext("MySPDevInstance");
    //spContext.Credentials = new NetworkCredential("username", "password");
    //using (var clientContext = spContext.CreateUserClientContextForSPHost())
    // clientContext.Load(clientContext.Web, web => web.Title);
    // clientContext.ExecuteQuery();
    // Response.Write(clientContext.Web.Title);
    string contextTokenString = TokenHelper.GetContextTokenFromRequest(Request);
    if (contextTokenString != null)
    // Get context token
    contextToken = TokenHelper.ReadAndValidateContextToken(contextTokenString, Request.Url.Authority);
    // Get access token
    sharepointUrl = new Uri(Request.QueryString["SPAppWebUrl"]);
    accessToken = TokenHelper.GetAccessToken(contextToken, sharepointUrl.Authority).AccessToken;
    // Pass the access token to the button event handler.
    Button1.CommandArgument = accessToken;
    protected void Button1_Click(object sender, EventArgs e)
    // Retrieve the access token that the Page_Load method stored
    // in the button's command argument.
    string accessToken = ((Button)sender).CommandArgument;
    if (IsPostBack)
    sharepointUrl = new Uri(Request.QueryString["SPAppWebUrl"]);
    // REST/OData URL section
    string oDataUrl = "/_api/Web/lists/getbytitle('Diagrams In Idea Generator')/items?$select=Title,Diagram,SharingStatus";
    // HTTP Request and Response construction section
    HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(sharepointUrl.ToString() + oDataUrl);
    request.Method = "GET";
    request.Accept = "application/atom+xml";
    request.ContentType = "application/atom+xml;type=entry";
    request.Headers.Add("Authorization", "Bearer " + accessToken);
    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    // Response markup parsing section
    XDocument oDataXML = XDocument.Load(response.GetResponseStream(), LoadOptions.None);
    XNamespace atom = "http://www.w3.org/2005/Atom";
    XNamespace d = "http://schemas.microsoft.com/ado/2007/08/dataservices";
    XNamespace m = "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata";
    List<XElement> entries = oDataXML.Descendants(atom + "entry")
    .Elements(atom + "content")
    .Elements(m + "properties")
    .ToList();
    var entryFieldValues = from entry in entries
    select new
    Character = entry.Element(d + "Title").Value,
    Actor = entry.Element(d + "Diagram").Value,
    CastingStatus = entry.Element(d + "SharingStatus").Value
    GridView1.DataSource = entryFieldValues;
    GridView1.DataBind();
    Any ideas what I might be doing wrong

    Hi ,
    Use the below code
    Public string GetAccessToken(){
    string sharePointSiteUrlHost =  Page.Request["SPHostUrl"].Tostring();
    string AccessToken = tokenHelper.GetS2SAccessTokenWithWindowsIdentity(sharePointSiteUrlHost, Request.LogonUserIdentity);
    return accessToken;
    Than initialize the ClientCOntext with the below Method
     private static ClientContext GetClientContextWithAccessTokenString(string targetUrl, object accessToken)
                ClientContext clientContext = new ClientContext(targetUrl);
                clientContext.AuthenticationMode = ClientAuthenticationMode.Anonymous;
                clientContext.FormDigestHandlingEnabled = false;
                clientContext.ExecutingWebRequest +=
                    delegate(object oSender, WebRequestEventArgs webRequestEventArgs)
                        webRequestEventArgs.WebRequestExecutor.WebRequest.UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)";
                        webRequestEventArgs.WebRequestExecutor.RequestHeaders["Authorization"] =
                            "Bearer " + accessToken;
                return clientContext;
    use this clientCOntext and it will work.
    Do not use
    SharePointContextProvider
    Whenever you see a reply and if you think is helpful,Vote As Helpful! And whenever you see a reply being an answer to the question of the thread, click Mark As Answer

Maybe you are looking for

  • Need to know how to find out the Variant associated with a background job

    Hello, Plz help me in finding out how to find the variant associated with a background job. I need to know which variant does the program picks up when it runs the scheduled background job. There are so many variants that exist. How do I figure out w

  • Ipw2200-fw error

    I am new to arch, but I have gotten a working arch installation with xfce (lxdm isnt working at the moment but that is a problem for another topic). However, on startup, the package ipw2200-fw returns an error (-2), so the wireless doesnt work immedi

  • Approval Workflow at Attribute level

    Hello, can anyone guide me how to achieve approval workflow at Attribute level. OIM 9.1.0.1/2 supports workflow for self profile update but it is not at attribute level & i need some approach to achieve this workflow at attribute level. Thank-You Rah

  • BC and Dreamweaver CS4 template file extensions

    I'm building a site suing BC extension for Dreamweaver CS4, but I can't get the templates to work. If I create them in Dreamweaver with the .dwt file extension, BC doesn't recognise them when they are uploaded. If I create them in BC control panel, t

  • ONT status?

    I called tech support yesterday, and after waiting an hour, I was told my ONT "went into a coma" and that "this has been happening a lot recently". I asked specifically what he meant by "into a coma" since I consider myself significantly technical an