⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stnet.pas

📁 条码控件: 一维条码控件 二维条码控件 PDF417Barcode MaxiCodeBarcode
💻 PAS
📖 第 1 页 / 共 5 页
字号:
(* ***** BEGIN LICENSE BLOCK *****
 * Version: MPL 1.1
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is TurboPower SysTools
 *
 * The Initial Developer of the Original Code is
 * TurboPower Software
 *
 * Portions created by the Initial Developer are Copyright (C) 1996-2002
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *
 * ***** END LICENSE BLOCK ***** *)

{*********************************************************}
{* SysTools: StNet.pas 4.03                              *}
{*********************************************************}
{* SysTools: Base Unit for Network Components            *}
{*********************************************************}

{$I StDefine.inc}

{$H+} {Huge strings}

unit StNet;

interface

uses
  Windows, Classes, StBase, StDate, StNetApi, StConst;

type
  TStNetItemType = (nitUnknown, nitLocalUser, nitGlobalUser, nitLocalGroup,
                    nitGlobalGroup, nitComputer, nitInterdomainTrust,
                    nitWorkstationTrust, nitServerTrust, nitShare);

  TStNetSidType  = (nstNone, nstUser, nstGroup, nstDomain, nstAlias,
                    nstWellKnownGroup, nstDeletedAccount, nstInvalid, nstUnknown,
                    nstComputer);

  TStNetUserPrivType     = (uptUnknown, uptGuest, uptUser, uptAdmin);
  TStNetUserAuthPrivType = (uaptPrint, uaptCommunications, uaptServer,
                            uaptAccounts);
  TStNetUserAuthPrivSet  = set of TStNetUserAuthPrivType;

  TStNetShareType = (stUnknown, stDisk, stPrint, stDevice, stIPC, stSpecial);

  TStNetServerPlatformType = (sptUnknown, sptDOS, sptOS2, sptNT, sptOSF, sptVMS);

  TStNetServerType = (nsvtWorkstation, nsvtServer, nsvtSQLServer, nsvtDomainCtrl,
                      nsvtDomainBackupCtrl, nsvtTimeSource, nsvtAFP, nsvtNovell,
                      nsvtDomainMember, nsvtPrintQServer, nsvtDialinServer,
                      nsvtUNIXServer, nsvtNT, nsvtWFW, nsvtMFPN, nsvtServerNT,
                      nsvtPotentialBrowser, nsvtBackupBrowser, nsvtMasterBrowser,
                      nsvtDomainMaster, nsvtOSF, nsvtVMS, nsvtWindows,
                      nsvtDFS, nsvtClusterNT, nsvtTerminalServer, nsvtDCE,
                      nsvtAlternateXPORT, nsvtLocalListOnly, nsvtDomainEnum);

  TStNetServerSet  = set of TStNetServerType;

  TStNetUserLogonTimes = array[TStDayType] of array[0..23] of Boolean;

  TStNetServerRoleType = (srtUnknown, srtStandAlone, srtMember, srtBackup,
                          strPrimary);

  TStNetwork = class;

  TStSidRecord = record
    Value : Pointer;
    ValueS: string;
    Length: DWord;
    Usage : TStNetSidType;
  end;

  TStNetItem = class(TObject)
   private
    FNetwork : TStNetwork;
    FItemType: TStNetItemType;
    FName    : string;
    FServer  : string;
   protected
    FComment : string;
    constructor CreateEx(AName, AComment, AServer:
                         string; AItemType: TStNetItemType);
   public
    constructor Create;
    destructor Destroy; override;

    property Comment : string
      read FComment;
    property ItemType: TStNetItemType
      read FItemType;
    property Name    : string
      read FName;
    property Server  : string
      read FServer;
  end;

  TStNetUserItem = class(TStNetItem)
   private
    FFullName : string;
    FID       : Cardinal;
    FGroupList: TStrings;
    FUserData : Pointer;
    FSidRecord: TStSidRecord;
    FDomain   : string;
    FWorkStationList : TStrings;
   protected
    function GetAccountDisabled      : Boolean;
    function GetAccountExpires       : TStDateTimeRec;
    function GetBadPasswordCount     : Cardinal;
    function GetDomain               : string;
    function GetFullName             : string;
    function GetGroupItemList        : TStringList;
    function GetHomeDirectory        : string;
    function GetHomeDrive            : string;
    function GetLastLogon            : TStDateTimeRec;
    function GetLastLogoff           : TStDateTimeRec;
    function GetLockedOut            : Boolean;
    function GetName                 : string;
    function GetNoUserPasswordChange : Boolean;
    function GetNumberOfLogons       : Cardinal;
    function GetOperatorPrivilege    : TStNetUserAuthPrivSet;
    function GetPasswordNeverExpires : Boolean;
    function GetPasswordExpired      : Boolean;
    function GetPasswordLastChanged  : TStDateTimeRec;
    function GetPasswordNotRequired  : Boolean;
    function GetPrimaryGroup         : TStNetItem;
    function GetProfilePath          : string;
    function GetSid                  : TStSidRecord;
    function GetScriptPath           : string;
    function GetUserComment          : string;
    function GetUserPrivilege        : TStNetUserPrivType;
    function GetWorkstations         : TStrings;

    procedure SetAccountDisabled(Value: Boolean);
    procedure SetAccountExpires(Value: TStDateTimeRec);
    procedure SetComment(Value: string);
    procedure SetFullName(Value: string);
    procedure SetHomeDirectory(Value: string);
    procedure SetHomeDrive(Value: string);
    procedure SetLockedOut(Value: Boolean);
    procedure SetName(Value: string);
    procedure SetNoUserPasswordChange(Value: Boolean);
    procedure SetPasswordAdmin(Value: string);
    procedure SetPasswordNeverExpires(Value: Boolean);
    procedure SetPasswordExpired(Value: Boolean);
    procedure SetPasswordNotRequired(Value: Boolean);
    procedure SetPrimaryGroup(Value: TStNetItem);
    procedure SetProfilePath(Value: string);
    procedure SetScriptPath(Value: string);
    procedure SetUserComment(Value: string);
    procedure SetWorkstations(Value: TStrings);

    constructor CreateEx(AName, AComment, AServer: string;
                         AItemType: TStNetItemType);
    constructor CreateExEnum(AName, AComment, AServer, AFullName: string;
                             AGlobal: Boolean; AID: Cardinal);
   public
    destructor Destroy; override;
    procedure Delete;
    procedure Refresh;
    procedure AddToGroup(AGroup: TStNetItem);
    procedure RemoveFromGroup(AGroup: TStNetItem);

    procedure GetLogonHours(var LogonHours: TStNetUserLogonTimes);
    procedure SetLogonHours(LogonHours: TStNetUserLogonTimes);
    procedure SetPassword(OldPassword, NewPassword: string);

    property AccountDisabled     : Boolean
      read GetAccountDisabled      write SetAccountDisabled;
    property AccountExpires      : TStDateTimeRec
      read GetAccountExpires       write SetAccountExpires;
    property BadPasswordCount    : Cardinal
      read GetBadPasswordCount;
    property Comment             : string
      read FComment                write SetComment;
    property Domain              : string
      read GetDomain;
    property FullName            : string
      read GetFullName             write SetFullName;
    property Groups              : TStringList
      read GetGroupItemList;
    property HomeDirectory       : string
      read GetHomeDirectory        write SetHomeDirectory;
    property HomeDrive           : string
      read GetHomeDrive            write SetHomeDrive;
    property ID                  : Cardinal
      read FID;
    property LastLogon           : TStDateTimeRec
      read GetLastLogon;
    property LastLogoff          : TStDateTimeRec
      read GetLastLogoff;
    property LockedOut           : Boolean
      read GetLockedOut            write SetLockedOut;
    property Name                : string
      read GetName                 write SetName;
    property NoUserPasswordChange: Boolean
      read GetNoUserPasswordChange write SetNoUserPasswordChange;
    property NumberOfLogons      : Cardinal
      read GetNumberOfLogons;
    property OperatorPrivilege   : TStNetUserAuthPrivSet
      read GetOperatorPrivilege;
    property Password            : string
                                   write SetPasswordAdmin;
    property PasswordNeverExpires: Boolean
      read GetPasswordNeverExpires write SetPasswordNeverExpires;
    property PasswordExpired     : Boolean
      read GetPasswordExpired      write SetPasswordExpired;
    property PasswordLastChanged : TStDateTimeRec
      read GetPasswordLastChanged;
    property PasswordNotRequired : Boolean
      read GetPasswordNotRequired  write SetPasswordNotRequired;
    property PrimaryGroup        : TStNetItem
      read GetPrimaryGroup         write SetPrimaryGroup;
    property ProfilePath         : string
      read GetProfilePath          write SetProfilePath;
    property ScriptPath          : string
      read GetScriptPath           write SetScriptPath;
    property Sid                 : TStSidRecord
      read GetSid;
    property UserComment         : string
      read GetUserComment          write SetUserComment;
    property UserPrivilege       : TStNetUserPrivType
      read GetUserPrivilege;
    property Workstations        : TStrings
      read GetWorkstations         write SetWorkstations;
  end;

  TStNetGroupItem = class(TStNetItem)
   private
    FID       : Cardinal;
    FItemList : TStrings;
    FSidRecord: TStSidRecord;
    FDomain   : string;
   protected
    constructor CreateEx(AName, AComment, AServer: string;
                         AItemType: TStNetItemType);
    constructor CreateExEnum(AName, AComment, AServer: string; AID: Cardinal);

    function GetGroupItemList: TStringList;
    function GetDomain: string;
    function GetSid: TStSidRecord;
    function GetName: string;

    procedure SetComment(Value: string);
    procedure SetName(Value: string);
   public
    destructor Destroy; override;

    procedure AddToGroup(AItem: TStNetItem);
    procedure RemoveFromGroup(AItem: TStNetItem);
    procedure Delete;
    procedure Refresh;

    property Comment  : string read FComment write SetComment;
    property Name     : string read GetName write SetName;
    property ID       : Cardinal read FID;
    property Items    : TStringList read GetGroupItemList;
    property Sid      : TStSidRecord read GetSid;
    property Domain   : string read GetDomain;
  end;

  TStNetShareItem = class(TStNetItem)
   private
    FShareType : TStNetShareType;
   protected
    constructor CreateEx(AName, AComment, AServer: string;
                         AShareType: TStNetShareType);
   public
    property ShareType : TStNetShareType read FShareType;
  end;

  TStNetServerItem = class(TStNetItem)
   private
    FUserList    : TStringList;
    FGroupList   : TStringList;
    FDriveList   : TStringList;
    FShareList   : TStringList;
    FServerData  : Pointer;
    FServerMData0: Pointer;
    FServerMData1: Pointer;
    FServerMData2: Pointer;
    FServerMData3: Pointer;
   protected
    constructor CreateEx(AName, AComment: string);

    function GetUser(AName: string): TStNetUserItem;
    function GetGroup(AName: string): TStNetGroupItem;

    function GetDriveList: TStringList;
    function GetUserList: TStringList;
    function GetGroupList : TStringList;
    function GetShareList : TStringList;

    procedure SetComment(Value: string);

    function GetAnnounceRate: DWord;
    function GetAnnounceRateDelta: DWord;
    function GetDisconnectTime: DWord;
    function GetMaxUsers: DWord;
    function GetPlatform: TStNetServerPlatformType;
    function GetServerType: TStNetServerSet;
    function GetUserPath: string;
    function GetVisible: Boolean;
    function GetVersion: DWord;

    function GetMinPasswordLen: DWord;
    function GetMaxPasswordAge: DWord;
    function GetMinPasswordAge: DWord;
    function GetForceLogoff: TStTime;
    function GetPasswordHistoryLength: DWord;
    function GetRole: TStNetServerRoleType;
    function GetPrimaryDC: string;
    function GetDomainName: string;
    function GetDomainSid : TStSidRecord;
    function GetLockOutDuration : DWord;
    function GetLockoutObservationWindow: DWord;
    function GetLockoutThreshold: DWord;

    procedure SetMinPasswordLen(Value: DWord);
    procedure SetMaxPasswordAge(Value: DWord);
    procedure SetMinPasswordAge(Value: DWord);
    procedure SetForceLogoff(Value: TStTime);
    procedure SetPasswordHistoryLength(Value: DWord);
    procedure SetLockOutDuration(Value: DWord);
    procedure SetLockoutObservationWindow(Value: DWord);
    procedure SetLockoutThreshold(Value: DWord);

    procedure SetAnnounceRate(Value: DWord);
    procedure SetAnnounceRateDelta(Value: DWord);
    procedure SetDisconnectTime(Value: DWord);
    procedure SetMaxUsers(Value: DWord);
    procedure SetVisible(Value: Boolean);

    procedure RefreshM0;
    procedure RefreshM1;
    procedure RefreshM2;
    procedure RefreshM3;
   public
    destructor Destroy; override;

    function AddGroup(AName, ADescription: string; AGlobal: Boolean): TStNetGroupItem;
    function AddUser(AName, APassword: string; AGlobal: Boolean): TStNetUserItem;
    procedure Refresh;

    property AnnounceRate      : DWord
      read GetAnnounceRate write SetAnnounceRate;
    property AnnounceRateDelta : DWord
      read GetAnnounceRateDelta write SetAnnounceRateDelta;
    property Comment           : string
      read FComment write SetComment;
    property DisconnectTime    : DWord
      read GetDisconnectTime write SetDisconnectTime;
    property MaxUsers          : DWord
      read GetMaxUsers write SetMaxUsers;
    property Platform          : TStNetServerPlatformType
      read GetPlatform;
    property ServerType        : TStNetServerSet
      read GetServerType;
    property UserPath          : string
      read GetUserPath;
    property Version           : DWord
      read GetVersion;
    property Visible           : Boolean
      read GetVisible write SetVisible;

    { MODALS_INFO_0 }
    property MinPasswordLen        : DWord
      read GetMinPasswordLen write SetMinPasswordLen;
    property MaxPasswordAge        : DWord
      read GetMaxPasswordAge write SetMaxPasswordAge;
    property MinPasswordAge        : DWord
      read GetMinPasswordAge write SetMinPasswordAge;
    property ForceLogoff           : TStTime
      read GetForceLogoff    write SetForceLogoff;
    property PasswordHistoryLength : DWord
      read GetPasswordHistoryLength write SetPasswordHistoryLength;

    { MODALS_INFO_1 }
    property Role                  : TStNetServerRoleType
      read GetRole;
    property PrimaryDC             : string
      read GetPrimaryDC;

    { MODALS_INFO_2 }
    property DomainName            : string
      read GetDomainName;
    property DomainSid             : TStSidRecord
      read GetDomainSid;

    { MODALS_INFO_3 }
    property LockOutDuration       : DWord

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -