AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Win32/Win64 API (native code) Delphi Existiert Benutzer+Passwort am System?
Thema durchsuchen
Ansicht
Themen-Optionen

Existiert Benutzer+Passwort am System?

Ein Thema von FriFra · begonnen am 11. Jul 2003 · letzter Beitrag vom 29. Jul 2003
Antwort Antwort
Seite 1 von 2  1 2      
Benutzerbild von FriFra
FriFra

Registriert seit: 19. Apr 2003
1.291 Beiträge
 
Delphi 2005 Professional
 
#1

Existiert Benutzer+Passwort am System?

  Alt 11. Jul 2003, 10:20
Ich habe 2 strings mit Benutzernamen und Passwort... nun will ich prüfen, ob der bettr. User auch am System existiert und vorallem, ob das angegebene Passwort stimmt.
  Mit Zitat antworten Zitat
Gast
(Gast)

n/a Beiträge
 
#2

Re: Existiert Benutzer+Passwort am System?

  Alt 11. Jul 2003, 10:27
Auf NT schaust du mit LogonUser() ob du ein gültiges Token (i.e. Handle) zurückbekommst. Wenn ja, war die User/Password Kombination korrekt.
  Mit Zitat antworten Zitat
Benutzerbild von r_kerber
r_kerber

Registriert seit: 11. Feb 2003
Ort: Trittau
3.538 Beiträge
 
Delphi XE Professional
 
#3

Re: Existiert Benutzer+Passwort am System?

  Alt 11. Jul 2003, 10:28
Falls Du mit System eine Datenbank meinst: Einfach Anmeldung versuchen und anschleißend eventuelle Exception auswerten.
  Mit Zitat antworten Zitat
Benutzerbild von FriFra
FriFra

Registriert seit: 19. Apr 2003
1.291 Beiträge
 
Delphi 2005 Professional
 
#4

Re: Existiert Benutzer+Passwort am System?

  Alt 11. Jul 2003, 11:50
Zitat von Assarbad:
Auf NT schaust du mit LogonUser() ob du ein gültiges Token (i.e. Handle) zurückbekommst. Wenn ja, war die User/Password Kombination korrekt.
Genau das habe ich gesucht . Danke!
  Mit Zitat antworten Zitat
Benutzerbild von Motzi
Motzi

Registriert seit: 6. Aug 2002
Ort: Wien
598 Beiträge
 
Delphi XE2 Professional
 
#5

Re: Existiert Benutzer+Passwort am System?

  Alt 11. Jul 2003, 13:47
Du wirst allerdings ein Problem haben - unter Win2k muss der Prozess das SE_TCB_NAME Privilege haben, andernfalls scheitert LogonUser und GetLastError liefert ERROR_PRIVILEGE_NOT_HELD! Und das SE_TCB_NAME Privilege ist nur Prozessen der Trusted Computing Base vorbehalten - dem System selbst und den Services
Manuel Pöter
  Mit Zitat antworten Zitat
Gast
(Gast)

n/a Beiträge
 
#6

Re: Existiert Benutzer+Passwort am System?

  Alt 11. Jul 2003, 14:59
Zitat:
Remarks
The LOGON32_LOGON_NETWORK logon type is the fastest, but there are two limitations. First, the function returns an impersonation token, not a primary token. You cannot use this token directly in the CreateProcessAsUser function. However, you can call the DuplicateTokenEx function to convert the token to a primary token, and then use it in CreateProcessAsUser. Second, if you convert the token to a primary token and use it in CreateProcessAsUser to start a process, the new process will not be able to access other network resources, such as remote servers or printers, through the redirector. An exception is that if the network resource is not access-controlled, then the new process will be able to access it.

The SE_TCB_NAME privilege is not required for this function unless you are logging onto a Passport account.


Windows 2000: The process calling LogonUser requires the SE_TCB_NAME privilege. If the calling process does not have this privilege, LogonUser fails and GetLastError returns ERROR_PRIVILEGE_NOT_HELD. In some cases, the process that calls LogonUser must also have the SE_CHANGE_NOTIFY_NAME privilege enabled; otherwise, LogonUser fails and GetLastError returns ERROR_ACCESS_DENIED. This privilege is not required for the local system account or accounts that are members of the administrators group. By default, SE_CHANGE_NOTIFY_NAME is enabled for all users, but some administrators may disable it for everyone. For more information about privileges, see Privileges.



The account being logged on, that is, the account specified by lpszUsername, must have the necessary account rights. For example, to log on a user with the LOGON32_LOGON_INTERACTIVE flag, the user (or a group to which the user belongs) must have the SE_INTERACTIVE_LOGON_NAME account right. For a list of the account rights that affect the various logon operations, see Account Rights Constants.

A user is considered logged on if at least one token exists. If you call CreateProcessAsUser and then close the token, the system considers the user as still logged on until the process (and all child processes) have ended.

If the LogonUser call is successful, the system notifies network providers that the logon occurred by calling the provider's NPLogonNotify entry-point function.
Danke Motzi, haette man vielleicht erwaehnen sollen BTW: Es geht eh nur bei Services oder wenn der Admin sich selbst die Policy aendert, denn Win32 APIs funzen nicht so einfach von Treibern aus

Nachtrag: Man sollte also einen Service und dann die Anwendung haben. Service schickt Daten an Anwendung und umgekehrt (i.e. IPC).
  Mit Zitat antworten Zitat
Benutzerbild von FriFra
FriFra

Registriert seit: 19. Apr 2003
1.291 Beiträge
 
Delphi 2005 Professional
 
#7

Re: Existiert Benutzer+Passwort am System?

  Alt 11. Jul 2003, 20:30
Also ich habe unter XP und 2003 keine Probleme mit dem Befehl... unter NT4 funktioniert es leider nicht... die Sache mit dem Service ist mir eigentlich zu umständlich! Gibt es vielleicht noch einen anderen Weg?

Im Moment verwende ich folgrnden Code:
Delphi-Quellcode:
var
  MyToken: cardinal;
begin
  MyToken := 0;
  try
    LogonUser(PChar(trim(RequestInfo.AuthUsername)), '',
      PChar(trim(RequestInfo.AuthPassword)), LOGON32_LOGON_BATCH,
      LOGON32_PROVIDER_DEFAULT, MyToken);
  except
  end;
  if MyToken <> 0 then
  begin
    //Name und Passwort sind gültig
    ...
  Mit Zitat antworten Zitat
Benutzerbild von sakura
sakura

Registriert seit: 10. Jun 2002
Ort: München
11.412 Beiträge
 
Delphi 11 Alexandria
 
#8

Re: Existiert Benutzer+Passwort am System?

  Alt 11. Jul 2003, 20:34
Such bei MSDN mal nach ImpersonateUser, oder so ähnlich. Das ist etwas komplizierter, funktioniert dafür aber auch in normalen Anwendungen.

......
Daniel W.
Ich bin nicht zurück, ich tue nur so
  Mit Zitat antworten Zitat
Gast
(Gast)

n/a Beiträge
 
#9

Re: Existiert Benutzer+Passwort am System?

  Alt 11. Jul 2003, 20:57
@sakura, das macht nicht viel sinn. du brauchst das token eines eingeloggten users (noch mal der name der API: ImpersonateLoggedonUser ... eine andere API mit aehnlichem namen gibts nicht) . das bekommst du nur mit LogonUser ... oder indem du das token des aktuellen users benutzt.

tokens zusammenbasteln darf eben nur die TCB

Ergo: ich kenne keine leichtere moeglichkeit. ich schau nochmal bei Brown rein, aber ich denke es gibt keine bessere variante.
  Mit Zitat antworten Zitat
Benutzerbild von sakura
sakura

Registriert seit: 10. Jun 2002
Ort: München
11.412 Beiträge
 
Delphi 11 Alexandria
 
#10

Re: Existiert Benutzer+Passwort am System?

  Alt 11. Jul 2003, 21:13
@Assarbad: Du hast recht, da habe ich etwas durcheinander gebracht. Anders hatte ich es auch nicht genutzt - war halt schon gut eineinhalb Jahre her, daß ich es gebraucht hatte...

@FriFra: Sorry.

......
Daniel W.
Ich bin nicht zurück, ich tue nur so
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 1 von 2  1 2      


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 09:25 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz