1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
Dim strUrlA = "Http://www.AAA.fr"
Dim strURLB As String = "Http://www.BBBB.fr?Filename=fichier.xml"
Dim strUser As String = "toto"
Dim strPWD As String = "tata"
Using client As New CookieAwareWebClient
Dim urlRefer As String = "https:///www.AAA.fr/authSAML/" 'ici je capte la méthode POST au moment de l''authentification dans l''outil développement FIrefox Réseau
Dim reqparm As New Specialized.NameValueCollection
reqparm.Add("BackURL", "/login/ConnexionConfirmationAction.do") 'avec les paramètres attendus
reqparm.Add("appId", "3")
reqparm.Add("ssoCas", "false")
reqparm.Add("protocol", "")
reqparm.Add("authRequestId", "")
reqparm.Add("login", strUser)
reqparm.Add("password", strPWD)
client.Credentials = New NetworkCredential(strUser, strPWD, "na")
client.Headers.Add("Content-Type", "application/x-www-form-urlencoded")
Dim responsebytes As Byte() = client.UploadValues(urlRefer, "POST", reqparm)
Dim responsebody = Encoding.UTF8.GetString(responsebytes)
' le responsebody me dit "tu es identifié" !!!!!! chouettte'
Using fs As Stream = client.OpenRead("https://www.AAAA.fr/authSAML/login/LoginDispatchAction.do?v=3.4.3&appId=510&domain=na&backURL=Http://www.BBBB.fr?Filename=fichier.xml") 'j''ai récup cet URL via l''outil dev aussi
Dim sr As StreamReader = New StreamReader(fs)
Console.WriteLine(sr.ReadToEnd())
'au lieu de me renvoyer le flux XML, ça me renvoit un flux HTML comme le responsebody mais qui me dit cette fois " Tu n''es pas authentifié sur AAAAA "
End Using
End Using |
Partager