2015-01-16 15 views
6

Mam do czynienia z dość osobliwym problemem. Musimy uruchomić usługę Listy w naszej farmie SharePoint. Uwierzytelnianie w sieci jest stowarzyszone za pomocą logowania jednokrotnego Oracle, ale mamy konta skonfigurowane do automatyzacji, które mogą realizować żądania internetowe. Korzystając z AAM, mamy "wewnętrzny" URL skonfigurowany do automatyzacji po stronie serwera, który omija bezpośrednio AD, a wszystko inne zostaje przekazane do SSO.New-WebServiceProxy nie uwierzytelnia się z NTLM

Oto kod (sanitized), którego używam, aby spróbować uzyskać listę kolekcji.

$username = "DOMAIN\username" 
$password = "somepassword" 
$site = "https://sp.biz.com/sites/SiteCollection" 

$credentials = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $username, (ConvertTo-SecureString $password -AsPlainText -Force) 

$proxy = New-WebServiceProxy -Uri "$site/_vti_bin/Lists.asmx" -Credentials $credentials 

$proxy.GetListCollection() 

Jestem hitem z 403, kiedy używam tego kodu.

Wyjątek wywołujący "GetListCollection" z argumentem "0" (-ów): "Serwer nie może przetworzyć żądania ---> Odmowa dostępu (Wyjątek od HRESULT: 0x80070005 (E_ACCESSDENIED)).".

Jeśli zmienię $ site, aby użyć wewnętrznego adresu URL (ustawionego przez AAM) i uruchomię go na jednym z frontów, pomyślnie otrzymam kolekcję list. Teraz na początku myślałem, że jest problem z kontem i uprawnieniami, ale po uruchomieniu przechwytywania przez Fiddlera widzę, że nie jest on w ogóle uwierzytelniany.

Po uruchomieniu następującego polecenia cURL następuje uwierzytelnienie i pobranie kolekcji list. Soap.xml to tylko podstawowy pakiet GetListCollection skopiowany prosto z WDSL.

curl -v -u 'username':'pass' --ntlm -X POST -H "Content-Type: text/xml" --data-binary @soap.xml https://sp.biz.com/sites/SiteCollection/_vti_bin/Lists.asmx 

Oto zdezynfekowane szczegółowe dane z cURL.

* STATE: INIT => CONNECT handle 0x600056190; line 1029 (connection #-5000) 
* Hostname was NOT found in DNS cache 
* Trying <IPv6>... 
* STATE: CONNECT => WAITCONNECT handle 0x600056190; line 1082 (connection #0) 
    % Total % Received % Xferd Average Speed Time Time  Time Current 
           Dload Upload Total Spent Left Speed 
    0  0 0  0 0  0  0  0 --:--:-- --:--:-- --:--:--  0* Connected to sp.biz.com (<IPv6>) port 443 (#0) 
* successfully set certificate verify locations: 
* CAfile: /usr/ssl/certs/ca-bundle.crt 
    CApath: none 
* SSLv3, TLS handshake, Client hello (1): 
} [data not shown] 
* STATE: WAITCONNECT => PROTOCONNECT handle 0x600056190; line 1222 (connection #0) 
* SSLv3, TLS handshake, Server hello (2): 
{ [data not shown] 
* SSLv3, TLS handshake, CERT (11): 
{ [data not shown] 
* SSLv3, TLS handshake, Server finished (14): 
{ [data not shown] 
* SSLv3, TLS handshake, Client key exchange (16): 
} [data not shown] 
* SSLv3, TLS change cipher, Client hello (1): 
} [data not shown] 
* SSLv3, TLS handshake, Finished (20): 
} [data not shown] 
* SSLv3, TLS change cipher, Client hello (1): 
{ [data not shown] 
* SSLv3, TLS handshake, Finished (20): 
{ [data not shown] 
* SSL connection using TLSv1.2/DES-CBC3-SHA 
*  SSL certificate verify ok. 
* STATE: PROTOCONNECT => DO handle 0x600056190; line 1241 (connection #0) 
* Server auth using NTLM with user 'DOMAIN\username' 
> POST /sites/SiteCollection/_vti_bin/Lists.asmx HTTP/1.1 
> Authorization: NTLM <snip> 
> User-Agent: curl/7.39.0 
> Host: sp.biz.com 
> Accept: */* 
> Content-Type: text/xml 
> Content-Length: 0 
> 
* STATE: DO => DO_DONE handle 0x600056190; line 1314 (connection #0) 
* STATE: DO_DONE => WAITPERFORM handle 0x600056190; line 1441 (connection #0) 
* STATE: WAITPERFORM => PERFORM handle 0x600056190; line 1454 (connection #0) 
* HTTP 1.1 or later with persistent connection, pipelining supported 
< HTTP/1.1 401 Unauthorized 
* Server Microsoft-IIS/7.5 is not blacklisted 
< Server: Microsoft-IIS/7.5 
< SPRequestGuid: <snip> 
< WWW-Authenticate: NTLM <snip> 
< X-Powered-By: ASP.NET 
< MicrosoftSharePointTeamServices: 14.0.0.7006 
< X-MS-InvokeApp: 1; RequireReadOnly 
< Date: Fri, 16 Jan 2015 01:02:56 GMT 
< Content-Length: 0 
< Set-Cookie: BIGipServerserver_pool=<snip>; expires=Sat, 17-Jan-2015 01:02:56 GMT; path=/ 
< 
    0  0 0  0 0  0  0  0 --:--:-- --:--:-- --:--:--  0 
* Connection #0 to host sp.biz.com left intact 
* Issue another request to this URL: 'https://sp.biz.com/sites/SiteCollection/_vti_bin/Lists.asmx' 
* STATE: PERFORM => CONNECT handle 0x600056190; line 1601 (connection #-5000) 
* Found bundle for host sp.biz.com: 0x60006aef0 
* Re-using existing connection! (#0) with host sp.biz.com 
* Connected to sp.biz.com (<IPv6>) port 443 (#0) 
* STATE: CONNECT => DO handle 0x600056190; line 1075 (connection #0) 
* Server auth using NTLM with user 'DOMAIN\username' 
> POST /sites/SiteCollection/_vti_bin/Lists.asmx HTTP/1.1 
> Authorization: NTLM <snip> 
> User-Agent: curl/7.39.0 
> Host: sp.biz.com 
> Accept: */* 
> Content-Type: text/xml 
> Content-Length: 353 
> 
} [data not shown] 
* upload completely sent off: 353 out of 353 bytes 
* STATE: DO => DO_DONE handle 0x600056190; line 1314 (connection #0) 
* STATE: DO_DONE => WAITPERFORM handle 0x600056190; line 1441 (connection #0) 
* STATE: WAITPERFORM => PERFORM handle 0x600056190; line 1454 (connection #0) 
* HTTP 1.1 or later with persistent connection, pipelining supported 
< HTTP/1.1 200 OK 
< Cache-Control: private, max-age=0 
< Content-Type: text/xml; charset=utf-8 
* Server Microsoft-IIS/7.5 is not blacklisted 
< Server: Microsoft-IIS/7.5 
< SPRequestGuid: <snip> 
< Set-Cookie: FedAuth=<snip>; expires=Fri, 16-Jan-2015 08:36:07 GMT; path=/; secure; HttpOnly 
< X-SharePointHealthScore: 0 
< X-AspNet-Version: 2.0.50727 
< Persistent-Auth: true 
< X-Powered-By: ASP.NET 
< MicrosoftSharePointTeamServices: 14.0.0.7006 
< X-MS-InvokeApp: 1; RequireReadOnly 
< Date: Fri, 16 Jan 2015 01:02:56 GMT 
< Content-Length: 104088 
< Vary: Accept-Encoding 
< 
{ [data not shown] 
* STATE: PERFORM => DONE handle 0x600056190; line 1626 (connection #0) 
100 101k 100 101k 100 353 219k 762 --:--:-- --:--:-- --:--:-- 219k 
* Connection #0 to host sp.biz.com left intact 

Każda pomoc jest bardzo doceniana. Nie jestem przeciwny rozwiązaniu C# przez PowerShell, jeśli brakuje cmdletów.


01-16-2015 12:13 PM EST Aktualizacja - zaktualizowałem pytanie odzwierciedla sugestię HighlyUnavailable i zawarte nagłówki z wychwytywania Fiddler.

Oto odkażone nagłówki ze skryptu PowerShell:

CONNECT sp.biz.com:443 HTTP/1.1 
Host: sp.biz.com 
Connection: Keep-Alive 
HTTP/1.1 200 Connection Established 
FiddlerGateway: Direct 
StartTime: 12:14:46.372 
Connection: close 
------------------------------------------------------------------ 
GET https://sp.biz.com/sites/SiteCollection/_vti_bin/Lists.asmx HTTP/1.1 
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 2.0.50727.5485) 
Host: sp.biz.com 
Connection: Keep-Alive 
HTTP/1.1 200 OK 
Cache-Control: private, max-age=0 
Content-Type: text/html; charset=utf-8 
Server: Microsoft-IIS/7.5 
SPRequestGuid: <snip> 
X-SharePointHealthScore: 0 
X-AspNet-Version: 2.0.50727 
X-Powered-By: ASP.NET 
MicrosoftSharePointTeamServices: 14.0.0.7006 
X-MS-InvokeApp: 1; RequireReadOnly 
Date: Fri, 16 Jan 2015 17:14:46 GMT 
Connection: keep-alive 
Content-Length: 9066 
Set-Cookie: BIGipServerserver_pool=<snip>; expires=Sat, 17-Jan-2015 17:14:46 GMT; path=/ 
Vary: Accept-Encoding 
------------------------------------------------------------------ 
GET https://sp.biz.com/_vti_bin/Lists.asmx?disco HTTP/1.1 
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 2.0.50727.5485) 
Host: sp.biz.com 
HTTP/1.1 200 OK 
Cache-Control: private 
Content-Type: text/xml; charset=utf-8 
Server: Microsoft-IIS/7.5 
SPRequestGuid: <snip> 
X-SharePointHealthScore: 0 
X-AspNet-Version: 2.0.50727 
X-Powered-By: ASP.NET 
MicrosoftSharePointTeamServices: 14.0.0.7006 
X-MS-InvokeApp: 1; RequireReadOnly 
Date: Fri, 16 Jan 2015 17:14:46 GMT 
Connection: close 
Content-Length: 747 
------------------------------------------------------------------ 
CONNECT sp.biz.com:443 HTTP/1.1 
Host: sp.biz.com 
Connection: Keep-Alive 
HTTP/1.1 200 Connection Established 
FiddlerGateway: Direct 
StartTime: 12:14:47.505 
Connection: close 
------------------------------------------------------------------ 
GET https://sp.biz.com/_vti_bin/Lists.asmx?wsdl HTTP/1.1 
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 2.0.50727.5485) 
Host: sp.biz.com 
HTTP/1.1 200 OK 
Cache-Control: private 
Content-Type: text/xml; charset=utf-8 
Server: Microsoft-IIS/7.5 
SPRequestGuid: <snip> 
X-SharePointHealthScore: 0 
X-AspNet-Version: 2.0.50727 
X-Powered-By: ASP.NET 
MicrosoftSharePointTeamServices: 14.0.0.7006 
X-MS-InvokeApp: 1; RequireReadOnly 
Date: Fri, 16 Jan 2015 17:14:46 GMT 
Connection: close 
Content-Length: 72672 
Set-Cookie: BIGipServerserver_pool=<snip>; expires=Sat, 17-Jan-2015 17:14:47 GMT; path=/ 
Vary: Accept-Encoding 
------------------------------------------------------------------ 
CONNECT sp.biz.com:443 HTTP/1.1 
Host: sp.biz.com 
Connection: Keep-Alive 
HTTP/1.1 200 Connection Established 
FiddlerGateway: Direct 
StartTime: 12:14:48.727 
Connection: close 
------------------------------------------------------------------ 
POST https://sp.biz.com/_vti_bin/Lists.asmx HTTP/1.1 
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 2.0.50727.5485) 
Content-Type: text/xml; charset=utf-8 
SOAPAction: "http://schemas.microsoft.com/sharepoint/soap/GetListCollection" 
Host: sp.biz.com 
Content-Length: 321 
Expect: 100-continue 
HTTP/1.1 500 Internal Server Error 
Cache-Control: private 
Content-Type: text/xml; charset=utf-8 
Server: Microsoft-IIS/7.5 
X-AspNet-Version: 2.0.50727 
X-Powered-By: ASP.NET 
MicrosoftSharePointTeamServices: 14.0.0.7006 
X-MS-InvokeApp: 1; RequireReadOnly 
Date: Fri, 16 Jan 2015 17:14:48 GMT 
Content-Length: 459 
Set-Cookie: BIGipServerserver_pool=686493706.47873.0000; expires=Sat, 17-Jan-2015 17:14:48 GMT; path=/ 
------------------------------------------------------------------ 

Oto nagłówki polecenia zawinięte.

CONNECT sp.biz.com:443 HTTP/1.1 
Host: sp.biz.com:443 
User-Agent: curl/7.39.0 
Connection: Keep-Alive 
Content-Type: text/xml 
HTTP/1.1 200 Connection Established 
FiddlerGateway: Direct 
StartTime: 12:21:07.928 
Connection: close 
------------------------------------------------------------------ 
POST https://sp.biz.com/sites/SiteCollection/_vti_bin/Lists.asmx HTTP/1.1 
Authorization: NTLM <snip>= 
User-Agent: curl/7.39.0 
Host: sp.biz.com 
Accept: */* 
Content-Type: text/xml 
Content-Length: 0 
HTTP/1.1 401 Unauthorized 
Server: Microsoft-IIS/7.5 
SPRequestGuid: <snip> 
WWW-Authenticate: NTLM <snip> 
X-Powered-By: ASP.NET 
MicrosoftSharePointTeamServices: 14.0.0.7006 
X-MS-InvokeApp: 1; RequireReadOnly 
Date: Fri, 16 Jan 2015 17:21:07 GMT 
Content-Length: 0 
Set-Cookie: BIGipServerserver_pool=<snip>; expires=Sat, 17-Jan-2015 17:21:07 GMT; path=/ 
Proxy-Support: Session-Based-Authentication 
------------------------------------------------------------------ 
POST https://sp.biz.com/sites/SiteCollection/_vti_bin/Lists.asmx HTTP/1.1 
Authorization: NTLM <snip> 
User-Agent: curl/7.39.0 
Host: sp.biz.com 
Accept: */* 
Content-Type: text/xml 
Content-Length: 417 
HTTP/1.1 200 OK 
Cache-Control: private, max-age=0 
Content-Type: text/xml; charset=utf-8 
Server: Microsoft-IIS/7.5 
SPRequestGuid: <snip> 
Set-Cookie: FedAuth=<snip>; expires=Sat, 17-Jan-2015 03:20:50 GMT; path=/; secure; HttpOnly 
X-SharePointHealthScore: 0 
X-AspNet-Version: 2.0.50727 
Persistent-Auth: true 
X-Powered-By: ASP.NET 
MicrosoftSharePointTeamServices: 14.0.0.7006 
X-MS-InvokeApp: 1; RequireReadOnly 
Date: Fri, 16 Jan 2015 17:21:07 GMT 
Content-Length: 66628 
Vary: Accept-Encoding 
------------------------------------------------------------------ 

Odpowiedz

0

Nigdy nie znalazłem rozwiązania problemu, ale mogę wyjaśnić, dlaczego. W naszym środowisku korzystamy z uwierzytelniania opartego na formularzach na podstawie naszego identyfikatora SSO Oracle Identity Foundation z SAML v1.1.

Podczas próby uwierzytelnienia przekierowuje użytkownika do pojedynczego logowania, ale klient próbuje użyć protokołu NTLM w odniesieniu do rzeczywistych interfejsów WWW zamiast pojedynczego logowania. Aby to zadziałało, musisz uwzględnić nagłówek X-FORMS_BASED_AUTH_ACCEPTED: f w swoim żądaniu, aby rzeczywiście uwierzytelnił się przy użyciu NTLM w stosunku do WFE (a nie SSO).

Oto problem: nie można dodawać nagłówków do New-WebServiceProxy w PowerShell (do 4.0 - jeszcze nie wprowadziłem 5). Jedyne zalecenie, które mogę zrobić dla innych osób mających problemy, to postępować zgodnie z sugestiami HighlyUnavailable lub użyć Invoke-WebRequest i budować połączenia SOAP ręcznie.

Jedynym problemem jest to, że Invoke-WebRequest może odgadnąć kodowanie, więc oto jak się nad tym rozwinęłam. Jeśli ktokolwiek ma sugestie dotyczące obejścia problemu z kodowaniem, jestem uszy.

# Set your credentials here. 
$UserName = 'BartSimpson' 
$Password = '3atmMySh0rtz!' 
$Domain = 'SF' 
$SecurePassword = ConvertTo-SecureString -String $Password -AsPlainText -Force 
$Credentials = New-Object System.Management.Automation.PSCredential (($Domain + "\" + $UserName), $SecurePassword) 

# SOAP request headers and body 
$BaseHeaders = @{"X-FORMS_BASED_AUTH_ACCEPTED" = 'f'; 
       "SOAPAction" = "`"http://schemas.microsoft.com/sharepoint/soap/GetListCollection`""; 
       "Content-Type" = "text/xml; charset=utf-8"} 
$SOAP = @" 
<?xml version="1.0" encoding="utf-8"?> 
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soap:Body> 
    <GetListCollection xmlns="http://schemas.microsoft.com/sharepoint/soap/" /> 
    </soap:Body> 
</soap:Envelope> 
"@ 
# Gives us a random temp file to pipe output to 
$TmpFile = [System.IO.Path]::GetTempFileName() 
Invoke-WebRequest -Uri $URL -Headers $BaseHeaders -Credential $Credentials -Method POST -Body $SOAP -OutFile $TmpFile 
# Get the outfile with UTF8 encoding 
[xml]$Result = Get-Content -Raw -Path $TmpFile -Encoding UTF8 
# Remove the temporary file 
Remove-Item $TmpFile 

Wygląda na to, że to długa droga, ale działa, jeśli nalegasz na używanie PowerShell.

Przełączyłem się na python-suds i udało mi się zrobić to, co było mi potrzebne.

4

Łączymy tutaj dwie zasadniczo różne techniki.

$proxy = New-WebServiceProxy -Uri "$site/_vti_bin/Lists.asmx" -UseDefaultCredential $proxy.PreAuthenticate = $TRUE $proxy.Credentials = $credentials

UseDefaultCredential będzie próbował zdać aktualnie zalogowany w systemie Windows użytkownika domeny do serwisu. Jednak ustawiasz także Poświadczenia. Normalnie byłoby użyć -Credential $credentials (patrz http://technet.microsoft.com/en-us/library/hh849841.aspx)

Zawinięcie polecenia używasz jest bardziej zbliżona do korzystania -Credential: -u jest równoważny.

Zamiast tego spróbuj użyć czegoś takiego, jak $proxy = New-WebServiceProxy -Uri "$site/_vti_bin/Lists.asmx" -Credential $credentials.

Jeśli to nie zadziała, zmień pytanie tak, aby zawierało nagłówki zwracane z połączenia SSO Oracle - może to oznaczać, że po prostu nie prosi o dane uwierzytelniające.

+0

Dzięki za dane wejściowe. Próbowałem kilku różnych kombinacji i żaden z nich nie działa. Moje pierwotne zrozumienie polega na tym, że umieszczając w tym miejscu '-UseDefaultCredentials', wykona anonimowy dostęp do pierwszego połączenia, dopóki nie otrzyma wyzwania uwierzytelnienia. Dodałem również żądane nagłówki zarówno dla cURL, jak i PowerShell do oryginalnego tematu. – Taylor

+1

@TaylorB To może ale nie musi pomóc, ale 'curl -u' wyśle ​​poświadczenia przy pierwszym połączeniu. Powershell prawdopodobnie nie będzie i czeka na 401 przed wysłaniem poświadczeń. Ja [napisałem o tym w odniesieniu do 'Invoke-WebRequest'] (http://stackoverflow.com/a/27951845/3905079), ale podstawowy kod, który sprawia, że ​​połączenie jest prawdopodobnie takie samo dla' New-WebServiceProxy'. – briantist

Powiązane problemy