Skip to content

Instantly share code, notes, and snippets.

@nddipiazza
Last active February 22, 2018 18:21
Show Gist options
  • Select an option

  • Save nddipiazza/9c73ea1766a39b4665fb633a23805e40 to your computer and use it in GitHub Desktop.

Select an option

Save nddipiazza/9c73ea1766a39b4665fb633a23805e40 to your computer and use it in GitHub Desktop.
#!/bin/bash
echo -n Enter Sharepoint Username:
read sharepointUsername
echo -n Enter Sharepoint Password:
read -s sharepointPassword
echo ""
echo "Enter ADFS STS Trust endpoint (e.g. https://server.com/adfs/services/trust/2005/usernamemixed)"
read stsUrl
echo ""
uuid=$(uuidgen)
curl -X POST \
${stsUrl} \
-H 'Content-Type: application/soap+xml' \
-H 'Cache-Control: no-cache' \
-d '<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"
xmlns:ps="http://schemas.microsoft.com/Passport/SoapServices/PPCRL"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:wssc="http://schemas.xmlsoap.org/ws/2005/02/sc"
xmlns:wst="http://schemas.xmlsoap.org/ws/2005/02/trust">
<s:Header>
<wsa:Action s:mustUnderstand="1">http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue</wsa:Action>
<wsa:To s:mustUnderstand="1">'${stsUrl}'</wsa:To>
<wsa:MessageID>urn:uuid:'${uuid}'</wsa:MessageID>
<wsse:Security>
<wsse:UsernameToken wsu:Id="user">
<wsse:Username>'${sharepointUsername}'</wsse:Username>
<wsse:Password><![CDATA['${sharepointPassword}']]></wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</s:Header>
<s:Body>
<wst:RequestSecurityToken Id="RST0">
<wst:RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue</wst:RequestType>
<wsp:AppliesTo>
<wsa:EndpointReference>
<wsa:Address>urn:federation:MicrosoftOnline</wsa:Address>
</wsa:EndpointReference>
</wsp:AppliesTo>
<wst:KeyType>http://schemas.xmlsoap.org/ws/2005/05/identity/NoProofKey</wst:KeyType>
</wst:RequestSecurityToken>
</s:Body>
</s:Envelope>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment