Einzelnen Beitrag anzeigen

Metschu

Registriert seit: 31. Dez 2006
151 Beiträge
 
Delphi 10.2 Tokyo Starter
 
#16

AW: Login auf Homepage mit Indy

  Alt 19. Feb 2013, 21:29
So, hier jetzt der Quelltext (Auszug):
Code:
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, height=device-height, user-scalable=yes,initial-scale=1.0, maximum-scale=5.0, minimum-scale=1.0">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-16">
<meta http-equiv="cache-control" content="no-cache">
<meta name="description" content="">
<title>Main LogIn</title>
<link rel="stylesheet" href="files/Dyn.css">
</head>
<body class="fitMldoc">
<div class="fitMlbody">
<div class="content">
<div class="c_box_mb">
<table class="b_top" cellpadding="0" cellspacing="0">
<tr>
<td class="tab_a_3">Main Login</td><td class="tab_ia_3"><a class="link02" href="start.swe?SWECmd=Logoff">Logoff</a></td>
</tr>
</table>
<Form method="POST" action="/start.swe?" name="Form1">
<table>
<tr>
<td class="pad_t w150X">Benutzername</td><td><input type="text" Name="SWEUserName" class="w130X"></td>
</tr>
<tr>
<td class="pad_t max200X">Passwort:</td><td><input type="Password" Name="SWEPassword" class="w130X"></td>
</tr>
<tr>
<td colspan="2">
<br>
<input Type="hidden" Name="SWECmd" Value="ExecuteLogin"><input Type="hidden" Name="SWENeedContext" Value="false">
<div class="bg_teaser_first" onclick="document.Form1.submit();" onmousedown="this.className='bg_teaser_first_md';" onmouseup="this.className='bg_teaser_first';" onmouseover="this.className='bg_teaser_first_md';" onmouseout="this.className='bg_teaser_first';">
<table class="c_in" cellpadding="0" cellspacing="0">
<tr>
<td class="w100XC"><img src="files/password2.gif" alt="" class="s_img40"></td><td>Anmelden</td><td class="c_rightcell_4"><img src="files/pfeil-vor.gif" alt="" width="4px" height="8px"></td>
... {ab hier nur noch Tabelle}

Hier die Post-Daten von FireBug:
Code:

SWECmd   ExecuteLogin
SWENeedContext   false
SWEPassword   Passwort {hier natürlich die richtigen Daten}
SWEUserName   Name1 Name2 {Namen mit Leerzeichen}

SWEUserName=Name1+Name2&SWEPassword=Passwort&SWECmd=ExecuteLogin&SWENeedContext=false
Die Antwort vom Server:
Code:
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<META http-equiv="cache-control" content="no-cache">
<META http-equiv="REFRESH" content="0;URL=start.swe?SWECmd=GotoView&amp;SWEView=Show+Login+Status">
</HEAD>
</HTML>
Nach dem Erfolgten LogIn mittels Browser wird diese URL angezeigt:
Code:
 https://intra.net/start.swe?SWECmd=GotoView&SWEView=Show+Login+Status
Und mein Code:

Delphi-Quellcode:
procedure TMainForm.Button2Click(Sender: TObject);
VAR IdHTTP:TIdHTTP; Params:TIdMultiPartFormDataStream;
    IdSSLIOHandlerSocketOpenSSL:TIdSSLIOHandlerSocketOpenSSL;
    IdCookieManager:TIdCookieManager; GetList:TStringList;

BEGIN
  IdHTTP := TIdHTTP.Create(NIL);
  GetList := TStringList.Create;
  IdCookieManager := TIdCookieManager.Create(NIL);
  IdSSLIOHandlerSocketOpenSSL := TIdSSLIOHandlerSocketOpenSSL.Create(NIL);
  Params := TIdMultiPartFormDataStream.Create;
  TRY
    IdSSLIOHandlerSocketOpenSSL.SSLOptions.Method := sslvSSLv3;
    IdSSLIOHandlerSocketOpenSSL.SSLOptions.Mode := sslmUnassigned;
    IdHTTP.IOHandler := IdSSLIOHandlerSocketOpenSSL;
    IdHTTP.CookieManager := IdCookieManager;
    IdHTTP.AllowCookies := TRUE;

    Params.AddFormField('SWEUserName', String(UTF8Encode(LoginName)));
    Params.AddFormField('SWEpassword', String(UTF8Encode(Passwort)));
    Params.AddFormField('SWECmd', String(UTF8Encode('ExecuteLogin')));
    Params.AddFormField('SWEpassword', String(UTF8Encode('false')));

    GetList.Text := IdHTTP.Post(Startseite,params); {-> Startseite = https://intra.net/start.swe?}

    memo1.Lines.AddStrings(getlist); {-> Gleicher Quelltext wie Startseite vor einloggen}

  FINALLY
    FreeAndNil(Params);
    IdSSLIOHandlerSocketOpenSSL.Free;
    IdCookieManager.Free;
    GetList.Free;
    IdHTTP.Free;
  END;
END
Torsten
  Mit Zitat antworten Zitat