AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Gruppennamen ermitteln

Ein Thema von IB-Software · begonnen am 20. Aug 2006 · letzter Beitrag vom 20. Aug 2006
Antwort Antwort
IB-Software

Registriert seit: 20. Nov 2004
Ort: Berlin
16 Beiträge
 
Delphi 7 Professional
 
#1

Re: Gruppennamen ermitteln

  Alt 20. Aug 2006, 23:10
Habe die Fehler nun selbst gefunden. Hier der funktionierende Code:
Delphi-Quellcode:
function GetGroupName(index:integer):string;
const DOMAIN_ALIAS_RID_ADMINS = $00000220;
      DOMAIN_ALIAS_RID_GUESTS = $00000222;
      DOMAIN_ALIAS_RID_USERS = $00000221;
      SECURITY_WORLD_RID = $00000000;
      SECURITY_BUILTIN_DOMAIN_RID = $00000020;
      SECURITY_NT_AUTHORITY: TSIDIdentifierAuthority = (Value: (0, 0, 0, 0, 0, 5));
var    Error, rid:integer;
      NameSize, DomainNameSize:DWORD;
      sia:SID_IDENTIFIER_AUTHORITY;
      TargetComputer,DomainName, Name:pchar;
      sid:psid;
      sidType: SID_NAME_USE;
      APISuccess : boolean;
begin
  Case index of
        0 : Rid := DOMAIN_ALIAS_RID_ADMINS;
        1 : Rid := DOMAIN_ALIAS_RID_GUESTS;
        2 : Rid := DOMAIN_ALIAS_RID_USERS;
        3 : Rid := 0;
  end;
  TargetComputer := '';
  NameSize := 1024;
  DomainNameSize := 1024;
  GetMem(Name, 1024);
  GetMem(DomainName, 1024);
  sia := SECURITY_NT_AUTHORITY;

  If Rid = 0 then
        begin
         sia.Value[5] := 1;
         If AllocateAndInitializeSid(sia, 1, SECURITY_WORLD_RID , Rid, 0, 0, 0, 0, 0, 0, Sid) then
         begin
            APISuccess := LookupAccountSid(0, Sid,Name, NameSize, DomainName, DomainNameSize, sidType);
            if APISuccess then begin
                if Assigned(sid) then FreeSid(sid)
             end else begin
                 name := '';
             end;
          End;
      end else begin
         sia.Value[5] := 5 ;
         If AllocateAndInitializeSid(sia, 2, SECURITY_BUILTIN_DOMAIN_RID, Rid, 0, 0, 0, 0, 0, 0, Sid) then
         begin
             APISuccess := LookupAccountSid(0, Sid, Name, NameSize, DomainName, DomainNameSize, sidType);
             if APISuccess then begin
                if Assigned(sid) then FreeSid(sid)
             end else begin
                 name := '';
             end;
          End;
        End;
  result := Name;
end;

Ingo
IB-Software: Software für Entwickler
Z-UpMaker: http://www.zupmaker.de (Vista kompatibel)
IB-Zip-DLL: http://www.zip-dll.de (Vista kompatibel)
UpdateMaker: http://www.updatemaker.de (Vista kompatibel)
  Mit Zitat antworten Zitat
Antwort Antwort


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 17:29 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz