M
M
Maxim2017-05-15 23:23:18
PHP
Maxim, 2017-05-15 23:23:18

How to transfer user login on SharePoint to another site?

Good evening.
Please let me know if there is any solution.
There is a corporate portal on SharePoint and there is a site on php (also in the corporate network).
On the php site I keep a log of visits, in which, in addition to the standard information, I write data: user ip and PC name. But this information is not enough, it is also necessary to log the user's network login (AD login).
Authentication on both sites is implemented without manually entering a password, using windows authentication.
Exclusively by means of php, as I understand it, the user's login cannot be recognized.
Therefore, I created a small page on SharePoint that generates only one line - the user's login.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<%@ Page Language="C#" %>
<%@ Register tagprefix="SharePoint" namespace="Microsoft.SharePoint.WebControls" assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=34564634564567" %>
<WebPartPages:AllowFraming runat="server" />

<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
  <head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=10" />
    <title>Test</title>
  </head>
  <body>
    <asp:LoginName id="LoginName1" runat="server" FormatString ="UserLogin: {0}" /><br/>
  </body>
</html>

I transferred this page through an iframe to a php site. The result is a cross-domain iframe.
<iframe src="http://portal.sharepoint.ru/sites/SitePages/user.aspx" id='frame' width='700' height='50' frameborder='0'></iframe>

Iframe works, login is displayed correctly.
Is it possible somehow now using php to extract the content (content) of the page from this cross-domain iframe into a variable?
I also tried using curl (post and get) to access the desired SharePoint page, but it gives me a "401 not authorized" error. Although through the browser everything works fine. If you check the implemented curl within the same domain, then everything works. But when trying to retrieve data from another domain (in this case, SharePoint) - 401 error.
<?php
  $q = 'http://portal.sharepoint.ru/sites/SitePages/user.aspx';
  $p = array( 
    'Host' => 'portal.sharepoint.ru',
    'User-Agent' => 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.96 Safari/537.36',
    'Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
    'Accept-Encoding' => 'gzip, deflate, sdch',
    'Accept-Language' => 'ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4',
  ); 
  
  $ch = curl_init();
  curl_setopt ($ch, CURLOPT_URL,  $q);
  curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt ($ch, CURLOPT_POST, true);
  curl_setopt ($ch, CURLOPT_POSTFIELDS, $p);

  $content = curl_exec ($ch);
  echo $content;
?>

There are few rights on the SharePoint site and I can’t really change anything there. Is it possible to create aspx pages with the content I need.
There was also an idea to implement logging on the SharePoint site, which would work every time the iframe is launched. But on SharePoint, I don’t understand how this can be done using aspx + js.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Орхан Гасанлы, 2018-07-25
@vladzvezdin

Hello!
When creating a custom post type, you did not specify the taxonomy ownership.
EXAMPLE
To display records and categories by type:
Category 1
- record 1
- record 2
Category 2
- record 3
- record 4
2 loops should be used. - receives categories, the second receives posts to them.
Example - https://gist.github.com/DevinWalker/6fb2783c05b46a...

X
xmoonlight, 2017-05-15
@Maxim_SV

Exclusively by means of php, as I understand it, the user's login cannot be recognized.
Got it wrong: link .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question