├── .gitignore ├── D210-XE7 └── All.groupproj ├── LICENSE ├── README.md ├── resources ├── login.ico ├── login.svg ├── login_128x128.png ├── login_16x16.png ├── login_24x24.png ├── login_256x256.png ├── login_32x32.png ├── login_512x512.png ├── login_64x64.png └── screen-main.png ├── samples ├── TestActiveDirectory │ ├── D210-XE7 │ │ ├── TestActiveDirectory.dpr │ │ ├── TestActiveDirectory.dproj │ │ ├── TestActiveDirectory.res │ │ └── TestActiveDirectory_Icon.ico │ └── src │ │ ├── TestActiveDirectory.View.Main.dfm │ │ └── TestActiveDirectory.View.Main.pas └── samples.optset └── src ├── Core ├── ActiveDirectory.Client.Winapi.pas ├── ActiveDirectory.Client.pas └── ActiveDirectory.Types.pas ├── D210-XE7 ├── ActiveDirectory4Delphi.dpk ├── ActiveDirectory4Delphi.dproj └── ActiveDirectory4Delphi.res ├── Interfaces └── ActiveDirectory.Client.Intf.pas ├── Winapi ├── ActiveDirectory.Winapi.DllMapper.pas └── ActiveDirectory.Winapi.TLB.pas └── source.optset /.gitignore: -------------------------------------------------------------------------------- 1 | # Uncomment these types if you want even more clean repository. But be careful. 2 | # It can make harm to an existing project source. Read explanations below. 3 | # 4 | # Resource files are binaries containing manifest, project icon and version info. 5 | # They can not be viewed as text or compared by diff-tools. Consider replacing them with .rc files. 6 | #*.res 7 | # 8 | # Type library file (binary). In old Delphi versions it should be stored. 9 | # Since Delphi 2009 it is produced from .ridl file and can safely be ignored. 10 | #*.tlb 11 | # 12 | # Diagram Portfolio file. Used by the diagram editor up to Delphi 7. 13 | # Uncomment this if you are not using diagrams or use newer Delphi version. 14 | #*.ddp 15 | # 16 | # Visual LiveBindings file. Added in Delphi XE2. 17 | # Uncomment this if you are not using LiveBindings Designer. 18 | #*.vlb 19 | # 20 | # Deployment Manager configuration file for your project. Added in Delphi XE2. 21 | # Uncomment this if it is not mobile development and you do not use remote debug feature. 22 | #*.deployproj 23 | # 24 | # C++ object files produced when C/C++ Output file generation is configured. 25 | # Uncomment this if you are not using external objects (zlib library for example). 26 | #*.obj 27 | # 28 | 29 | # Delphi compiler-generated binaries (safe to delete) 30 | *.exe 31 | *.dll 32 | *.bpl 33 | *.bpi 34 | *.dcp 35 | *.so 36 | *.apk 37 | *.drc 38 | *.map 39 | *.dres 40 | *.rsm 41 | *.tds 42 | *.dcu 43 | *.lib 44 | *.a 45 | *.o 46 | *.ocx 47 | 48 | # Delphi autogenerated files (duplicated info) 49 | *.cfg 50 | *.hpp 51 | *Resource.rc 52 | 53 | # Delphi local files (user-specific info) 54 | *.local 55 | *.identcache 56 | *.projdata 57 | *.tvsconfig 58 | *.dsk 59 | 60 | # Delphi history and backups 61 | __history/ 62 | __recovery/ 63 | *.~* 64 | 65 | # Castalia statistics file (since XE7 Castalia is distributed with Delphi) 66 | *.stat 67 | 68 | # Boss dependency manager vendor folder https://github.com/HashLoad/boss 69 | modules/ 70 | 71 | # Custom 72 | out/ 73 | *Thumbs.db -------------------------------------------------------------------------------- /D210-XE7/All.groupproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | {5B27D07F-CA3E-4D38-BA6A-1C802702B219} 4 | 5 | 6 | 7 | 8 | 9 | 10 | ..\src\D210-XE7\ActiveDirectory4Delphi.dproj 11 | 12 | 13 | 14 | Default.Personality.12 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 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | {75ACF6F6-EE54-45C4-8BDE-F5BE29B69CDF} 51 | Debug;Release 52 | Win32;Win64 53 | True 54 | 55 | 56 | {BFF1BEB7-1767-4894-BAD0-C8C3C68CC914} 57 | Debug;Release 58 | Win32;Win64 59 | True 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) EdZava, ZvDev. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | demo 3 |

4 | 5 | # ActiveDirectory4Delphi 6 | 7 | Delphi basic library for validation and authentication of LDAP users in Active Directory. 8 | 9 | ![release](https://img.shields.io/github/v/release/EdZava/VCL-ActiveDirectory4Delphi?style=flat-square) 10 | ![Delphi Supported Versions](https://img.shields.io/badge/Delphi%20Supported%20Versions-XE7%20and%20ever-blue.svg) 11 | ![Platforms](https://img.shields.io/badge/Supported%20platforms-Win32%20and%20Win64-red.svg) 12 | [![Twitter: ZavaDev](https://img.shields.io/twitter/follow/ZavaDev.svg?style=social)](https://twitter.com/ZavaDev) 13 | 14 | ## ⚙️ Installation 15 | 16 | * **Manual installation**: Add the following folders to your project, in *Project > Options > Resource Compiler > Directories and Conditionals > Include file search path* 17 | 18 | ``` 19 | ../VCL-ActiveDirectory4Delphi/src/Core 20 | ../VCL-ActiveDirectory4Delphi/src/Interfaces 21 | ../VCL-ActiveDirectory4Delphi/src/Winapi 22 | ``` 23 | 24 | ## ⚡️ Quickstart 25 | 26 | You need to use **ActiveDirectory.Client** 27 | 28 | ```pascal 29 | uses ActiveDirectory.Client; 30 | ``` 31 | 32 | * **Authenticate current user** 33 | 34 | ```pascal 35 | procedure Authenticate(UserPass: string); 36 | var 37 | CurrentUserName: string; 38 | CurrentDomainName: string; 39 | CurrentLDAPDomainName: string; 40 | begin 41 | if (not ActiveDirectoryClient.GetActiveDirectoryEnabled) then 42 | Exit; 43 | 44 | CurrentUserName := ActiveDirectoryClient.GetCurrentUserName; 45 | CurrentDomainName := ActiveDirectoryClient.GetCurrentDomainName(CurrentUserName); 46 | CurrentLDAPDomainName := ActiveDirectoryClient.GetCurrentLDAPDomainName(CurrentDomainName); 47 | 48 | if ActiveDirectoryClient.AuthenticateUser(CurrentLDAPDomainName, CurrentUserName, UserPass) then 49 | ShowMessage('ok') 50 | else 51 | ShowMessage('Fail'); 52 | end; 53 | ``` 54 | 55 | * **Validation user active** 56 | 57 | ```pascal 58 | procedure ValidationUserActive(DomainName, UserName: string); 59 | begin 60 | if ActiveDirectoryClient.GetUserActive(DomainName, UserName) then 61 | ShowMessage('ok') 62 | else 63 | ShowMessage('Fail'); 64 | end; 65 | ``` 66 | 67 | more information look at the unit [ActiveDirectory.Client](./src/Core/ActiveDirectory.Client.pas) 68 | 69 | ## ✨ App demo using library 70 | 71 | Download 72 | [Win32](https://github.com/EdZava/VCL-ActiveDirectory4Delphi/releases/latest/download/TestActiveDirectory-Win32.rar), 73 | [Win64](https://github.com/EdZava/VCL-ActiveDirectory4Delphi/releases/latest/download/TestActiveDirectory-Win64.rar) 74 | 75 | Application of example of using the library and information that could be recovered. 76 | 77 |

78 | demo 79 |

80 | 81 | ### Get Current Info 82 | 83 | Retrieve the information of the current section. 84 | 85 | ```log 86 | AllProviders = WinNT:,LDAP: 87 | CurrentUserName = usuario1 88 | CurrentDomainName = MYDOMAIN 89 | CurrentLDAPDomainName = DC=MYDOMAIN,DC=TEST 90 | ActiveDirectoryEnabled = True 91 | ``` 92 | 93 | ### Get User Info 94 | 95 | Retrieve user information using the domain and user indicated in the text boxes. 96 | 97 | ```log 98 | Param.Domain = MYDOMAIN 99 | Param.UserName = usuario1 100 | UserFind = True 101 | UserActive = True 102 | UserInfo.UID = usuario1 103 | UserInfo.UserName = usuario1 104 | UserInfo.Description = Descripcion del usuario 1 105 | UserInfo.Password.Expired = False 106 | UserInfo.Password.NeverExpires = False 107 | UserInfo.Password.CannotChange = False 108 | UserInfo.Disabled = False 109 | UserInfo.LockedOut = False 110 | UserInfo.Groups = gusuarios,Usuarios del dominio 111 | ``` 112 | 113 | ### Authenticate 114 | 115 | Authenticate using the domain and user indicated in the text boxes. 116 | 117 | ```log 118 | Param.Domain = MYDOMAIN 119 | Param.UserName = usuario1 120 | Param.UserPass = ********* 121 | Authenticated = True 122 | ``` 123 | 124 | ## Author 125 | 126 | 👤 **Zava** 127 | 128 | * Twitter: [@ZavaDev](https://twitter.com/ZavaDev) 129 | 130 | ## Show your support 131 | 132 | Give a ⭐️ if this project helped you! 133 | 134 | ### License 135 | 136 | ActiveDirectory4Delphi is [MIT licensed](./LICENSE). 137 | -------------------------------------------------------------------------------- /resources/login.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EdZava/VCL-ActiveDirectory4Delphi/2908d2c8a61e3714a24688d20c2ce9ad4db6a13e/resources/login.ico -------------------------------------------------------------------------------- /resources/login.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /resources/login_128x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EdZava/VCL-ActiveDirectory4Delphi/2908d2c8a61e3714a24688d20c2ce9ad4db6a13e/resources/login_128x128.png -------------------------------------------------------------------------------- /resources/login_16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EdZava/VCL-ActiveDirectory4Delphi/2908d2c8a61e3714a24688d20c2ce9ad4db6a13e/resources/login_16x16.png -------------------------------------------------------------------------------- /resources/login_24x24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EdZava/VCL-ActiveDirectory4Delphi/2908d2c8a61e3714a24688d20c2ce9ad4db6a13e/resources/login_24x24.png -------------------------------------------------------------------------------- /resources/login_256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EdZava/VCL-ActiveDirectory4Delphi/2908d2c8a61e3714a24688d20c2ce9ad4db6a13e/resources/login_256x256.png -------------------------------------------------------------------------------- /resources/login_32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EdZava/VCL-ActiveDirectory4Delphi/2908d2c8a61e3714a24688d20c2ce9ad4db6a13e/resources/login_32x32.png -------------------------------------------------------------------------------- /resources/login_512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EdZava/VCL-ActiveDirectory4Delphi/2908d2c8a61e3714a24688d20c2ce9ad4db6a13e/resources/login_512x512.png -------------------------------------------------------------------------------- /resources/login_64x64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EdZava/VCL-ActiveDirectory4Delphi/2908d2c8a61e3714a24688d20c2ce9ad4db6a13e/resources/login_64x64.png -------------------------------------------------------------------------------- /resources/screen-main.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EdZava/VCL-ActiveDirectory4Delphi/2908d2c8a61e3714a24688d20c2ce9ad4db6a13e/resources/screen-main.png -------------------------------------------------------------------------------- /samples/TestActiveDirectory/D210-XE7/TestActiveDirectory.dpr: -------------------------------------------------------------------------------- 1 | program TestActiveDirectory; 2 | 3 | uses 4 | Vcl.Forms, 5 | TestActiveDirectory.View.Main in '..\src\TestActiveDirectory.View.Main.pas' {frmMain}; 6 | 7 | {$R *.res} 8 | 9 | begin 10 | ReportMemoryLeaksOnShutdown := True; 11 | Application.Initialize; 12 | Application.MainFormOnTaskbar := True; 13 | Application.Title := 'Test Active Directory'; 14 | Application.CreateForm(TfrmMain, frmMain); 15 | Application.Run; 16 | end. 17 | -------------------------------------------------------------------------------- /samples/TestActiveDirectory/D210-XE7/TestActiveDirectory.dproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | {75ACF6F6-EE54-45C4-8BDE-F5BE29B69CDF} 4 | 16.0 5 | VCL 6 | TestActiveDirectory.dpr 7 | True 8 | Release 9 | Win32 10 | 3 11 | Application 12 | 13 | 14 | true 15 | 16 | 17 | true 18 | Base 19 | true 20 | 21 | 22 | true 23 | Base 24 | true 25 | 26 | 27 | true 28 | Base 29 | true 30 | 31 | 32 | true 33 | Cfg_1 34 | true 35 | true 36 | 37 | 38 | true 39 | Cfg_1 40 | true 41 | true 42 | 43 | 44 | true 45 | Base 46 | true 47 | 48 | 49 | true 50 | Cfg_2 51 | true 52 | true 53 | 54 | 55 | true 56 | Cfg_2 57 | true 58 | true 59 | 60 | 61 | 62 | true 63 | CompanyName=Zv;FileDescription=Test Active Directory;FileVersion=1.0.0.0;InternalName=VCL-ActiveDirectory;LegalCopyright=2020 ;LegalTrademarks=;OriginalFilename=VCL-ActiveDirectory;ProductName=VCL-ActiveDirectory;ProductVersion=1.0.0.0;Comments=By Zv 64 | 3082 65 | $(BDS)\bin\default_app.manifest 66 | System;Xml;Data;Datasnap;Web;Soap;Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;$(DCC_Namespace) 67 | TestActiveDirectory 68 | false 69 | false 70 | false 71 | false 72 | false 73 | ..\..\samples.optset 74 | 75 | 76 | TestActiveDirectory_Icon.ico 77 | 1033 78 | Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) 79 | dcldxBarRS21;ZIPBBoxD21;SSHBBoxCliD21;dxPScxSchedulerLnkRS21;rbTDBC1721;cxSchedulerRibbonStyleEventEditorRS21;JvMM;JvGlobus;JvManagedThreads;TeeTree2D21Tee9;CEF4Delphi;cxSchedulerRS21;PGPBBoxD21;dclRBBDE1721;FireDACPgDriver;DCPcrypt;JvCrypt;cxTreeListdxBarPopupMenuRS21;cxPivotGridRS21;DBXInterBaseDriver;DataSnapServer;DataSnapCommon;dclRBDBE1721;JvNet;dxGaugeControlRS21;JvDotNetCtrls;cxEditorsRS21;DbxCommonDriver;vclimg;cxPivotGridOLAPRS21;dxPSdxGaugeControlLnkRS21;dbxcds;dxTileControlRS21;DatasnapConnectorsFreePascal;JvXPCtrls;vcldb;rbIBE1721;cxTreeListRS21;ASiCBBoxD21;WPTools7_DXE7;PGPSSHBBoxD21;cxSpreadSheetRS21;dxBarExtItemsRS21;dxWizardControlRS21;madSecurity_;CustomIPTransport;dsnap;IndyIPServer;IndyCore;dxSkinsdxBarPainterRS21;dxOrgCRS21;TeeImage921;CloudService;dclRBE1721;FireDACIBDriver;dxPScxPCProdRS21;SSHBBoxSrvD21;JvDB;dxDockingRS21;rbDB1721;rbBDE1721;JvRuntimeDesign;dxLayoutControlRS21;dsnapxml;JclDeveloperTools;FireDACDb2Driver;dxSkinscxSchedulerPainterRS21;ManagedVCL;dxPSLnksRS21;dxPSdxDBOCLnkRS21;SSLBBoxSrvD21;cxLibraryRS21;dxELibD210;bindcompfmx;vcldbx;dxComnRS21;FireDACODBCDriver;RESTBackendComponents;SFTPBBoxSrvD21;cxDataRS21;ImagXpr6d;dbrtl;SSLBBoxCliD21;FireDACCommon;bindcomp;inetdb;JvPluginSystem;dxPScxTLLnkRS21;dxEdtrD210;DBXOdbcDriver;dclRBIBE1721;JvCmp;vclFireDAC;madDisAsm_;rbRCL1721;JvTimeFramework;xmlrtl;ibxpress;madShell_;cxExportRS21;dxDBEdD210;OverbyteIcsDXe7Run;MIMEBBoxD21;FireDACCommonDriver;dxFlowChartRS21;bindengine;vclactnband;soaprtl;TeePro921;rbDBDE1721;bindcompvcl;cxPageControlRS21;dxCoreRS21;Jcl;vclie;madExcept_;dxPSCoreRS21;XMLBBoxD21;dxPSdxDBTVLnkRS21;dxPScxCommonRS21;EQTLD210;dxADOServerModeRS21;FireDACMSSQLDriver;DBXInformixDriver;Intraweb;ZipMasterR;Cipher;dxPSTeeChartRS21;DataSnapServerMidas;rbRIDE1721;dsnapcon;DBXFirebirdDriver;HTTPBBoxCliD21;inet;SSLBBoxSrvIndy10D21;dxRibbonRS21;dxNavBarRS21;dxSkinsdxNavBarPainterRS21;rbIDE1721;FireDACMySQLDriver;soapmidas;vclx;PKIBBoxD21;cxBarEditItemRS21;dxSkinsCoreRS21;JvPascalInterpreter;DBXSybaseASADriver;dclRBADO1721;dxFireDACServerModeRS21;RESTComponents;SSLBBoxCliIndy10D21;TeeGL921;dbexpress;IndyIPClient;dxThemeRS21;JvBDE;FireDACSqliteDriver;FireDACDSDriver;dxDBXServerModeRS21;DBXSqliteDriver;rbADO1721;addict4db_d21;dxSkinsdxDLPainterRS21;dxRichEditControlRS21;addict4_d21;fmx;rbUSERDesign1721;PGPTLSBBoxD21;IndySystem;dxDBOrRS21;cxVerticalGridRS21;tethering;dxSpreadSheetRS21;JvDlgs;frxe21;vclib;inetdbbde;DataSnapClient;dxPScxPivotGridLnkRS21;ECQDBCD210;frx21;SMIMEBBoxD21;rbDIDE1721;DataSnapProviderClient;dxPSPrVwRibbonRS21;DBXSybaseASEDriver;rbTC1721;cxGridRS21;MetropolisUILiveTile;PDFBBoxD21;SFTPBBoxCliD21;vcldsnap;dxSpellCheckerRS21;fmxFireDAC;PKIECtrl21;DBXDb2Driver;EQDBTLD210;EQGridD210;DBXOracleDriver;TeeLanguage921;JvCore;vclribbon;PKISSHBBoxD21;dxtrmdRS21;rbRAP1721;OfficeBBoxD21;fmxase;vcl;dxBarExtDBItemsRS21;TeeImport921;DBXMSSQLDriver;IndyIPCommon;CodeSiteExpressPkg;dxGDIPlusRS21;TeeWorld921;XMLBBoxSecD21;dxPSDBTeeChartRS21;dxPSPrVwAdvRS21;DataSnapFireDAC;FireDACDBXDriver;dxPSdxSpreadSheetLnkRS21;dxForumLibD210;soapserver;rbDAD1721;xtradev210;dxdbtrRS21;inetdbxpress;JvAppFrm;SSHBBoxCliIndy10D21;FireDACInfxDriver;dxPScxGridLnkRS21;dxPSdxFCLnkRS21;rbTCUI1721;PKIEDB21;JvDocking;adortl;NoteXp6d;BaseBBoxD21;SevenZip;JvWizards;madBasic_;FireDACASADriver;dxExELD210;JvHMI;CloudBBoxD21;WpSpell_DXE7;JvBands;dxTabbedMDIRS21;TeeMaker121;madKernel_;emsclientfiredac;rtl;TeeDB921;DbxClientDriver;dxPScxSSLnkRS21;dxPScxExtCommonRS21;dxPSdxOCLnkRS21;rbDBE1721;rbRTL1721;dxPSdxLCLnkRS21;frxDB21;dxMapControlRS21;JvSystem;dcldxBarDBNavRS21;DataSnapNativeClient;svnui;dclRBFireDAC1721;JvControls;IndyProtocols;DBXMySQLDriver;cxPivotGridChartRS21;dxGrEdD210;O408_r;bindcompdbx;kbmMemRunDXE7Std;EDIBBoxD21;JvJans;JvPrintPreview;JvPageComps;JvStdCtrls;cxSchedulerTreeBrowserRS21;TeeUI921;TLZRW;dxmdsRS21;JvCustom;parsdpk;FireDACADSDriver;vcltouch;WPViewPDF3LIB;MailBBoxD21;dxServerModeRS21;emsclient;dxSkinscxPCPainterRS21;rbCIDE1721;VCLRESTComponents;FireDAC;VclSmp;dxBarDBNavRS21;dxRibbonCustomizationFormRS21;DataSnapConnectors;cxSchedulerGridRS21;fmxobj;Tee921;dxPageControlD210;JclVcl;dxPScxVGridLnkRS21;svn;dxBarRS21;rbUSER1721;FireDACOracleDriver;fmxdae;rbFireDAC1721;bdertl;PGPMIMEBBoxD21;FireDACMSAccDriver;DataSnapIndy10ServerTransport;FTPSBBoxCliD21;$(DCC_UsePackage) 80 | 81 | 82 | 1033 83 | Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;$(DCC_Namespace) 84 | CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= 85 | TestActiveDirectory_Icon.ico 86 | ZIPBBoxD21;SSHBBoxCliD21;dxPScxSchedulerLnkRS21;cxSchedulerRibbonStyleEventEditorRS21;cxSchedulerRS21;PGPBBoxD21;FireDACPgDriver;DCPcrypt;cxTreeListdxBarPopupMenuRS21;DBXInterBaseDriver;DataSnapServer;DataSnapCommon;dxGaugeControlRS21;cxEditorsRS21;DbxCommonDriver;vclimg;cxPivotGridOLAPRS21;dxPSdxGaugeControlLnkRS21;dbxcds;dxTileControlRS21;DatasnapConnectorsFreePascal;vcldb;cxTreeListRS21;ASiCBBoxD21;PGPSSHBBoxD21;dxBarExtItemsRS21;dxWizardControlRS21;CustomIPTransport;dsnap;IndyIPServer;IndyCore;dxOrgCRS21;CloudService;FireDACIBDriver;dxPScxPCProdRS21;SSHBBoxSrvD21;dxDockingRS21;dxLayoutControlRS21;dsnapxml;JclDeveloperTools;FireDACDb2Driver;dxPSLnksRS21;dxPSdxDBOCLnkRS21;SSLBBoxSrvD21;cxLibraryRS21;bindcompfmx;FireDACODBCDriver;RESTBackendComponents;SFTPBBoxSrvD21;cxDataRS21;dbrtl;SSLBBoxCliD21;FireDACCommon;bindcomp;inetdb;dxPScxTLLnkRS21;DBXOdbcDriver;vclFireDAC;xmlrtl;ibxpress;cxExportRS21;OverbyteIcsDXe7Run;MIMEBBoxD21;FireDACCommonDriver;dxFlowChartRS21;bindengine;vclactnband;soaprtl;bindcompvcl;cxPageControlRS21;Jcl;vclie;dxPSCoreRS21;XMLBBoxD21;dxPSdxDBTVLnkRS21;dxPScxCommonRS21;dxADOServerModeRS21;FireDACMSSQLDriver;DBXInformixDriver;Intraweb;ZipMasterR;DataSnapServerMidas;dsnapcon;DBXFirebirdDriver;HTTPBBoxCliD21;inet;SSLBBoxSrvIndy10D21;dxRibbonRS21;dxNavBarRS21;FireDACMySQLDriver;soapmidas;vclx;PKIBBoxD21;DBXSybaseASADriver;dxFireDACServerModeRS21;RESTComponents;SSLBBoxCliIndy10D21;dbexpress;IndyIPClient;FireDACSqliteDriver;FireDACDSDriver;dxDBXServerModeRS21;DBXSqliteDriver;dxRichEditControlRS21;fmx;PGPTLSBBoxD21;IndySystem;dxDBOrRS21;cxVerticalGridRS21;tethering;dxSpreadSheetRS21;vclib;DataSnapClient;dxPScxPivotGridLnkRS21;SMIMEBBoxD21;DataSnapProviderClient;dxPSPrVwRibbonRS21;DBXSybaseASEDriver;cxGridRS21;MetropolisUILiveTile;PDFBBoxD21;SFTPBBoxCliD21;vcldsnap;dxSpellCheckerRS21;fmxFireDAC;PKIECtrl21;DBXDb2Driver;DBXOracleDriver;vclribbon;PKISSHBBoxD21;dxtrmdRS21;OfficeBBoxD21;fmxase;vcl;dxBarExtDBItemsRS21;DBXMSSQLDriver;IndyIPCommon;dxGDIPlusRS21;XMLBBoxSecD21;dxPSPrVwAdvRS21;DataSnapFireDAC;FireDACDBXDriver;dxPSdxSpreadSheetLnkRS21;soapserver;dxdbtrRS21;inetdbxpress;FireDACInfxDriver;dxPScxGridLnkRS21;dxPSdxFCLnkRS21;PKIEDB21;adortl;BaseBBoxD21;FireDACASADriver;CloudBBoxD21;dxTabbedMDIRS21;emsclientfiredac;rtl;DbxClientDriver;dxPScxSSLnkRS21;dxPScxExtCommonRS21;dxPSdxOCLnkRS21;dxPSdxLCLnkRS21;dxMapControlRS21;DataSnapNativeClient;IndyProtocols;DBXMySQLDriver;cxPivotGridChartRS21;O408_r;bindcompdbx;EDIBBoxD21;cxSchedulerTreeBrowserRS21;dxmdsRS21;FireDACADSDriver;vcltouch;MailBBoxD21;dxServerModeRS21;emsclient;VCLRESTComponents;FireDAC;VclSmp;dxBarDBNavRS21;dxRibbonCustomizationFormRS21;DataSnapConnectors;cxSchedulerGridRS21;fmxobj;JclVcl;dxPScxVGridLnkRS21;dxBarRS21;FireDACOracleDriver;fmxdae;PGPMIMEBBoxD21;FireDACMSAccDriver;DataSnapIndy10ServerTransport;FTPSBBoxCliD21;$(DCC_UsePackage) 87 | 88 | 89 | TestActiveDirectory_Icon.ico 90 | DEBUG;$(DCC_Define) 91 | true 92 | false 93 | true 94 | true 95 | true 96 | 97 | 98 | 1033 99 | false 100 | 101 | 102 | 1033 103 | CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= 104 | 105 | 106 | false 107 | TestActiveDirectory_Icon.ico 108 | false 109 | RELEASE;$(DCC_Define) 110 | 0 111 | 0 112 | 113 | 114 | 1033 115 | 116 | 117 | 1033 118 | CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= 119 | 120 | 121 | 122 | 123 | MainSource 124 | 125 | 126 |
frmMain
127 | dfm 128 |
129 | 130 | Cfg_2 131 | Base 132 | 133 | 134 | Base 135 | ..\..\samples.optset 136 | 137 | 138 | Cfg_1 139 | Base 140 | 141 |
142 | 143 | Delphi.Personality.12 144 | Application 145 | 146 | 147 | 148 | TestActiveDirectory.dpr 149 | 150 | 151 | Microsoft Office 2000 Sample Automation Server Wrapper Components 152 | Microsoft Office XP Sample Automation Server Wrapper Components 153 | 154 | 155 | 156 | 157 | 158 | TestActiveDirectory.exe 159 | true 160 | 161 | 162 | 163 | 164 | TestActiveDirectory.exe 165 | true 166 | 167 | 168 | 169 | 170 | TestActiveDirectory.exe 171 | true 172 | 173 | 174 | 175 | 176 | 1 177 | .dylib 178 | 179 | 180 | 0 181 | .bpl 182 | 183 | 184 | Contents\MacOS 185 | 1 186 | .dylib 187 | 188 | 189 | 1 190 | .dylib 191 | 192 | 193 | 194 | 195 | 1 196 | .dylib 197 | 198 | 199 | 0 200 | .dll;.bpl 201 | 202 | 203 | Contents\MacOS 204 | 1 205 | .dylib 206 | 207 | 208 | 1 209 | .dylib 210 | 211 | 212 | 213 | 214 | 1 215 | 216 | 217 | 1 218 | 219 | 220 | 221 | 222 | Contents 223 | 1 224 | 225 | 226 | 227 | 228 | ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 229 | 1 230 | 231 | 232 | 233 | 234 | res\drawable-normal 235 | 1 236 | 237 | 238 | 239 | 240 | library\lib\x86 241 | 1 242 | 243 | 244 | 245 | 246 | 1 247 | 248 | 249 | 1 250 | 251 | 252 | 253 | 254 | Contents 255 | 1 256 | 257 | 258 | 259 | 260 | library\lib\armeabi-v7a 261 | 1 262 | 263 | 264 | 265 | 266 | 1 267 | 268 | 269 | 1 270 | 271 | 272 | 273 | 274 | res\drawable-xlarge 275 | 1 276 | 277 | 278 | 279 | 280 | res\drawable-xhdpi 281 | 1 282 | 283 | 284 | 285 | 286 | 1 287 | 288 | 289 | 1 290 | 291 | 292 | 293 | 294 | res\drawable-xxhdpi 295 | 1 296 | 297 | 298 | 299 | 300 | library\lib\mips 301 | 1 302 | 303 | 304 | 305 | 306 | res\drawable 307 | 1 308 | 309 | 310 | 311 | 312 | Contents\MacOS 313 | 1 314 | 315 | 316 | 1 317 | 318 | 319 | 0 320 | 321 | 322 | 323 | 324 | Contents\MacOS 325 | 1 326 | .framework 327 | 328 | 329 | 0 330 | 331 | 332 | 333 | 334 | res\drawable-small 335 | 1 336 | 337 | 338 | 339 | 340 | 1 341 | 342 | 343 | 344 | 345 | Contents\MacOS 346 | 1 347 | 348 | 349 | 1 350 | 351 | 352 | Contents\MacOS 353 | 0 354 | 355 | 356 | 357 | 358 | classes 359 | 1 360 | 361 | 362 | 363 | 364 | 1 365 | 366 | 367 | 1 368 | 369 | 370 | 371 | 372 | 1 373 | 374 | 375 | 1 376 | 377 | 378 | 379 | 380 | res\drawable 381 | 1 382 | 383 | 384 | 385 | 386 | Contents\Resources 387 | 1 388 | 389 | 390 | 391 | 392 | 1 393 | 394 | 395 | 396 | 397 | 1 398 | 399 | 400 | 1 401 | 402 | 403 | 404 | 405 | 1 406 | 407 | 408 | library\lib\armeabi-v7a 409 | 1 410 | 411 | 412 | 0 413 | 414 | 415 | Contents\MacOS 416 | 1 417 | 418 | 419 | 1 420 | 421 | 422 | 423 | 424 | library\lib\armeabi 425 | 1 426 | 427 | 428 | 429 | 430 | res\drawable-large 431 | 1 432 | 433 | 434 | 435 | 436 | 0 437 | 438 | 439 | 0 440 | 441 | 442 | 0 443 | 444 | 445 | Contents\MacOS 446 | 0 447 | 448 | 449 | 0 450 | 451 | 452 | 453 | 454 | 1 455 | 456 | 457 | 1 458 | 459 | 460 | 461 | 462 | res\drawable-ldpi 463 | 1 464 | 465 | 466 | 467 | 468 | res\values 469 | 1 470 | 471 | 472 | 473 | 474 | 1 475 | 476 | 477 | 1 478 | 479 | 480 | 481 | 482 | res\drawable-mdpi 483 | 1 484 | 485 | 486 | 487 | 488 | res\drawable-hdpi 489 | 1 490 | 491 | 492 | 493 | 494 | 1 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | True 506 | True 507 | 508 | 509 | 12 510 | 511 | 512 | 513 | 514 |
515 | -------------------------------------------------------------------------------- /samples/TestActiveDirectory/D210-XE7/TestActiveDirectory.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EdZava/VCL-ActiveDirectory4Delphi/2908d2c8a61e3714a24688d20c2ce9ad4db6a13e/samples/TestActiveDirectory/D210-XE7/TestActiveDirectory.res -------------------------------------------------------------------------------- /samples/TestActiveDirectory/D210-XE7/TestActiveDirectory_Icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EdZava/VCL-ActiveDirectory4Delphi/2908d2c8a61e3714a24688d20c2ce9ad4db6a13e/samples/TestActiveDirectory/D210-XE7/TestActiveDirectory_Icon.ico -------------------------------------------------------------------------------- /samples/TestActiveDirectory/src/TestActiveDirectory.View.Main.dfm: -------------------------------------------------------------------------------- 1 | object frmMain: TfrmMain 2 | Left = 0 3 | Top = 0 4 | Caption = 'Test Active Directory' 5 | ClientHeight = 669 6 | ClientWidth = 792 7 | Color = clBtnFace 8 | Font.Charset = DEFAULT_CHARSET 9 | Font.Color = clWindowText 10 | Font.Height = -11 11 | Font.Name = 'Segoe UI' 12 | Font.Style = [] 13 | OldCreateOrder = False 14 | Position = poScreenCenter 15 | ShowHint = True 16 | OnCreate = FormCreate 17 | PixelsPerInch = 96 18 | TextHeight = 13 19 | object pnlPrinc: TPanel 20 | Left = 0 21 | Top = 0 22 | Width = 792 23 | Height = 41 24 | Align = alTop 25 | BevelOuter = bvNone 26 | ParentColor = True 27 | TabOrder = 0 28 | object btnGetCurrentInfo: TButton 29 | AlignWithMargins = True 30 | Left = 8 31 | Top = 5 32 | Width = 124 33 | Height = 31 34 | Margins.Left = 8 35 | Margins.Top = 5 36 | Margins.Right = 5 37 | Margins.Bottom = 5 38 | Align = alLeft 39 | Caption = 'Get Current Info' 40 | TabOrder = 0 41 | OnClick = btnGetCurrentInfoClick 42 | end 43 | end 44 | object edtLog: TMemo 45 | Left = 0 46 | Top = 106 47 | Width = 792 48 | Height = 522 49 | Hint = 'Log' 50 | Align = alClient 51 | BevelInner = bvNone 52 | BevelOuter = bvNone 53 | BorderStyle = bsNone 54 | Font.Charset = DEFAULT_CHARSET 55 | Font.Color = clWindowText 56 | Font.Height = -12 57 | Font.Name = 'Consolas' 58 | Font.Style = [] 59 | ParentFont = False 60 | PopupMenu = PopupMenu 61 | ReadOnly = True 62 | ScrollBars = ssVertical 63 | TabOrder = 2 64 | end 65 | object pnlCustomAuth: TPanel 66 | Left = 0 67 | Top = 41 68 | Width = 792 69 | Height = 65 70 | Align = alTop 71 | BevelOuter = bvNone 72 | ParentColor = True 73 | TabOrder = 1 74 | object edtDomain: TLabeledEdit 75 | Left = 9 76 | Top = 32 77 | Width = 124 78 | Height = 21 79 | EditLabel.Width = 40 80 | EditLabel.Height = 13 81 | EditLabel.Caption = 'Domain' 82 | TabOrder = 0 83 | OnChange = edtUserPassChange 84 | end 85 | object edtUserName: TLabeledEdit 86 | Left = 138 87 | Top = 32 88 | Width = 124 89 | Height = 21 90 | EditLabel.Width = 52 91 | EditLabel.Height = 13 92 | EditLabel.Caption = 'UserName' 93 | TabOrder = 1 94 | OnChange = edtUserPassChange 95 | end 96 | object edtUserPass: TLabeledEdit 97 | Left = 267 98 | Top = 32 99 | Width = 124 100 | Height = 21 101 | EditLabel.Width = 49 102 | EditLabel.Height = 13 103 | EditLabel.Caption = 'Password' 104 | TabOrder = 2 105 | OnChange = edtUserPassChange 106 | end 107 | object btnAuthenticate: TButton 108 | Left = 595 109 | Top = 30 110 | Width = 85 111 | Height = 25 112 | Caption = 'Authenticate' 113 | TabOrder = 5 114 | OnClick = btnAuthenticateClick 115 | end 116 | object btnGetUserInfo: TButton 117 | Left = 505 118 | Top = 30 119 | Width = 85 120 | Height = 25 121 | Caption = 'Get User Info' 122 | TabOrder = 4 123 | OnClick = btnGetUserInfoClick 124 | end 125 | object chkbxShowPassword: TCheckBox 126 | Left = 396 127 | Top = 34 128 | Width = 97 129 | Height = 17 130 | Caption = 'Show Password' 131 | TabOrder = 3 132 | OnClick = chkbxShowPasswordClick 133 | end 134 | end 135 | object pnlBtnsLog: TPanel 136 | Left = 0 137 | Top = 628 138 | Width = 792 139 | Height = 41 140 | Align = alBottom 141 | BevelOuter = bvNone 142 | ParentColor = True 143 | TabOrder = 3 144 | object btnCopyLog: TButton 145 | AlignWithMargins = True 146 | Left = 8 147 | Top = 5 148 | Width = 75 149 | Height = 31 150 | Hint = 'Copy Log To Clipboard' 151 | Margins.Left = 8 152 | Margins.Top = 5 153 | Margins.Right = 5 154 | Margins.Bottom = 5 155 | Align = alLeft 156 | Caption = 'Copy' 157 | TabOrder = 0 158 | OnClick = btnCopyLogClick 159 | end 160 | object btnClearLog: TButton 161 | AlignWithMargins = True 162 | Left = 88 163 | Top = 5 164 | Width = 75 165 | Height = 31 166 | Hint = 'Clear Log' 167 | Margins.Left = 0 168 | Margins.Top = 5 169 | Margins.Right = 5 170 | Margins.Bottom = 5 171 | Align = alLeft 172 | Caption = 'Clear' 173 | TabOrder = 1 174 | OnClick = btnClearLogClick 175 | end 176 | end 177 | object PopupMenu: TPopupMenu 178 | Left = 472 179 | Top = 320 180 | object Copy1: TMenuItem 181 | Action = EditCopy1 182 | end 183 | object SelectAll1: TMenuItem 184 | Action = EditSelectAll1 185 | end 186 | end 187 | object ActionList: TActionList 188 | Left = 400 189 | Top = 320 190 | object EditCopy1: TEditCopy 191 | Category = 'Edit' 192 | Caption = '&Copy' 193 | Hint = 'Copy|Copies the selection and puts it on the Clipboard' 194 | ImageIndex = 1 195 | ShortCut = 16451 196 | end 197 | object EditSelectAll1: TEditSelectAll 198 | Category = 'Edit' 199 | Caption = 'Select &All' 200 | Hint = 'Select All|Selects the entire document' 201 | ShortCut = 16449 202 | end 203 | end 204 | end 205 | -------------------------------------------------------------------------------- /samples/TestActiveDirectory/src/TestActiveDirectory.View.Main.pas: -------------------------------------------------------------------------------- 1 | unit TestActiveDirectory.View.Main; 2 | 3 | interface 4 | 5 | uses 6 | ActiveDirectory.Types, 7 | 8 | System.SysUtils, System.Classes, Vcl.Controls, Vcl.Forms, Vcl.StdCtrls, Vcl.ExtCtrls, Vcl.ActnList, 9 | Vcl.Menus, Vcl.StdActns, System.Actions; 10 | 11 | type 12 | TfrmMain = class(TForm) 13 | pnlPrinc: TPanel; 14 | edtLog: TMemo; 15 | btnGetCurrentInfo: TButton; 16 | pnlCustomAuth: TPanel; 17 | edtDomain: TLabeledEdit; 18 | edtUserName: TLabeledEdit; 19 | edtUserPass: TLabeledEdit; 20 | btnAuthenticate: TButton; 21 | pnlBtnsLog: TPanel; 22 | btnCopyLog: TButton; 23 | btnClearLog: TButton; 24 | btnGetUserInfo: TButton; 25 | PopupMenu: TPopupMenu; 26 | Copy1: TMenuItem; 27 | SelectAll1: TMenuItem; 28 | ActionList: TActionList; 29 | EditCopy1: TEditCopy; 30 | EditSelectAll1: TEditSelectAll; 31 | chkbxShowPassword: TCheckBox; 32 | procedure btnGetCurrentInfoClick(Sender: TObject); 33 | procedure btnAuthenticateClick(Sender: TObject); 34 | procedure edtUserPassChange(Sender: TObject); 35 | procedure FormCreate(Sender: TObject); 36 | procedure btnClearLogClick(Sender: TObject); 37 | procedure btnGetUserInfoClick(Sender: TObject); 38 | procedure btnCopyLogClick(Sender: TObject); 39 | procedure chkbxShowPasswordClick(Sender: TObject); 40 | private 41 | { Private declarations } 42 | procedure RefreshEnabledAuthenticate; 43 | procedure RefreshShowPassword; 44 | function GetMsgErrorLog(E: Exception): string; 45 | function GetPasswordLog: string; 46 | 47 | protected 48 | procedure AddLog(inMsg: string); 49 | procedure AddLogError(E: Exception); 50 | procedure AddLogUserInfo(inUserInfo: TADSIUserInfo); 51 | 52 | procedure AddLogSession(inSender: TObject; inMethod: TProc); 53 | function AddLogValueTry(inName: string; inMethodGetValue: TFunc): Boolean; 54 | procedure AddLogValueAbortOnFail(inName: string; inMethodGetValue: TFunc); 55 | 56 | public 57 | { Public declarations } 58 | end; 59 | 60 | var 61 | frmMain: TfrmMain; 62 | 63 | implementation 64 | 65 | uses 66 | ActiveDirectory.Client; 67 | 68 | {$R *.dfm} 69 | 70 | { TfrmMain } 71 | 72 | procedure TfrmMain.FormCreate(Sender: TObject); 73 | begin 74 | Self.RefreshEnabledAuthenticate; 75 | Self.RefreshShowPassword; 76 | end; 77 | 78 | procedure TfrmMain.btnCopyLogClick(Sender: TObject); 79 | begin 80 | edtLog.SelectAll; 81 | edtLog.CopyToClipboard; 82 | end; 83 | 84 | procedure TfrmMain.btnClearLogClick(Sender: TObject); 85 | begin 86 | edtLog.Lines.Clear; 87 | end; 88 | 89 | procedure TfrmMain.chkbxShowPasswordClick(Sender: TObject); 90 | begin 91 | Self.RefreshShowPassword; 92 | end; 93 | 94 | procedure TfrmMain.edtUserPassChange(Sender: TObject); 95 | begin 96 | Self.RefreshEnabledAuthenticate; 97 | end; 98 | 99 | procedure TfrmMain.RefreshEnabledAuthenticate; 100 | var 101 | ValidN1, ValidN2: Boolean; 102 | begin 103 | ValidN1 := (Trim(edtDomain.Text) <> '') and (Trim(edtUserName.Text) <> ''); 104 | ValidN2 := (ValidN1) and (Trim(edtUserPass.Text) <> ''); 105 | 106 | btnGetUserInfo.Enabled := ValidN1; 107 | btnAuthenticate.Enabled := ValidN2; 108 | end; 109 | 110 | procedure TfrmMain.RefreshShowPassword; 111 | begin 112 | if chkbxShowPassword.Checked then 113 | edtUserPass.PasswordChar := #0 114 | else 115 | edtUserPass.PasswordChar := '*'; 116 | end; 117 | 118 | function TfrmMain.GetMsgErrorLog(E: Exception): string; 119 | begin 120 | Result := 'Error.Class: ' + Trim(E.ClassName) + ' | ' + 'Error.Message: ' + Trim(E.Message) 121 | end; 122 | 123 | function TfrmMain.GetPasswordLog: string; 124 | begin 125 | if (chkbxShowPassword.Checked) then 126 | Result := edtUserPass.Text 127 | else 128 | Result := StringOfChar('*', Length(edtUserPass.Text)); 129 | end; 130 | 131 | procedure TfrmMain.AddLog(inMsg: string); 132 | begin 133 | edtLog.Lines.Add(inMsg); 134 | end; 135 | 136 | procedure TfrmMain.AddLogError(E: Exception); 137 | begin 138 | Self.AddLog('ERROR = ' + Self.GetMsgErrorLog(E)); 139 | end; 140 | 141 | procedure TfrmMain.AddLogUserInfo(inUserInfo: TADSIUserInfo); 142 | begin 143 | Self.AddLog('UserInfo.UID = ' + inUserInfo.UID); 144 | Self.AddLog('UserInfo.UserName = ' + inUserInfo.UserName); 145 | Self.AddLog('UserInfo.Description = ' + inUserInfo.Description); 146 | Self.AddLog('UserInfo.Password.Expired = ' + BoolToStr(inUserInfo.Password.Expired, True)); 147 | Self.AddLog('UserInfo.Password.NeverExpires = ' + BoolToStr(inUserInfo.Password.NeverExpires, True)); 148 | Self.AddLog('UserInfo.Password.CannotChange = ' + BoolToStr(inUserInfo.Password.CannotChange, True)); 149 | Self.AddLog('UserInfo.Disabled = ' + BoolToStr(inUserInfo.Disabled, True)); 150 | Self.AddLog('UserInfo.LockedOut = ' + BoolToStr(inUserInfo.LockedOut, True)); 151 | Self.AddLog('UserInfo.Groups = ' + inUserInfo.Groups); 152 | end; 153 | 154 | procedure TfrmMain.AddLogSession(inSender: TObject; inMethod: TProc); 155 | var 156 | Button: TButton; 157 | begin 158 | try 159 | Button := (inSender as TButton); 160 | 161 | Button.Enabled := False; 162 | try 163 | Self.AddLog('[ ' + Button.Caption + ' ]'); 164 | 165 | if Assigned(inMethod) then 166 | inMethod; 167 | 168 | Self.AddLog(''); 169 | finally 170 | Button.Enabled := True; 171 | end; 172 | except 173 | on E: Exception do 174 | begin 175 | if (not (E is EAbort)) then 176 | Self.AddLogError(E); 177 | end; 178 | end; 179 | end; 180 | 181 | function TfrmMain.AddLogValueTry(inName: string; inMethodGetValue: TFunc): Boolean; 182 | var 183 | Value: string; 184 | begin 185 | Value := ''; 186 | try 187 | try 188 | Value := inMethodGetValue; 189 | Result := True; 190 | except 191 | on E: Exception do 192 | begin 193 | Value := Self.GetMsgErrorLog(E); 194 | Result := False; 195 | end; 196 | end; 197 | finally 198 | Self.AddLog(inName + ' = ' + Value); 199 | end; 200 | end; 201 | 202 | procedure TfrmMain.AddLogValueAbortOnFail(inName: string; inMethodGetValue: TFunc); 203 | begin 204 | if (not Self.AddLogValueTry(inName, inMethodGetValue)) then 205 | Abort; 206 | end; 207 | 208 | procedure TfrmMain.btnGetCurrentInfoClick(Sender: TObject); 209 | begin 210 | Self.AddLogSession( 211 | Sender, 212 | procedure 213 | var 214 | CurrentUserName: string; 215 | CurrentDomainName: string; 216 | CurrentLDAPDomainName: string; 217 | AllProviders: string; 218 | begin 219 | {$REGION 'AllProviders'} 220 | Self.AddLogValueTry( 221 | 'AllProviders', 222 | function: string 223 | begin 224 | Result := ActiveDirectoryClient.GetAllProviders; 225 | AllProviders := Result; 226 | end 227 | ); 228 | {$ENDREGION} 229 | 230 | {$REGION 'CurrentUserName'} 231 | Self.AddLogValueAbortOnFail( 232 | 'CurrentUserName', 233 | function: string 234 | begin 235 | Result := ActiveDirectoryClient.GetCurrentUserName; 236 | CurrentUserName := Result; 237 | end 238 | ); 239 | 240 | edtUserName.Text := CurrentUserName; 241 | {$ENDREGION} 242 | 243 | {$REGION 'CurrentDomainName'} 244 | Self.AddLogValueAbortOnFail( 245 | 'CurrentDomainName', 246 | function: string 247 | begin 248 | Result := ActiveDirectoryClient.GetCurrentDomainName(CurrentUserName); 249 | CurrentDomainName := Result; 250 | end 251 | ); 252 | 253 | edtDomain.Text := CurrentDomainName; 254 | {$ENDREGION} 255 | 256 | {$REGION 'CurrentLDAPDomainName'} 257 | Self.AddLogValueTry( 258 | 'CurrentLDAPDomainName', 259 | function: string 260 | begin 261 | Result := ActiveDirectoryClient.GetCurrentLDAPDomainName(CurrentDomainName); 262 | CurrentLDAPDomainName := Result; 263 | end 264 | ); 265 | {$ENDREGION} 266 | 267 | {$REGION 'ActiveDirectoryEnabled'} 268 | Self.AddLogValueTry( 269 | 'ActiveDirectoryEnabled', 270 | function: string 271 | var 272 | Resultado: Boolean; 273 | begin 274 | Resultado := ActiveDirectoryClient.GetActiveDirectoryEnabled; 275 | Result := BoolToStr(Resultado, True); 276 | CurrentDomainName := Result; 277 | end 278 | ); 279 | {$ENDREGION} 280 | end 281 | ); 282 | end; 283 | 284 | procedure TfrmMain.btnGetUserInfoClick(Sender: TObject); 285 | begin 286 | Self.AddLogSession( 287 | Sender, 288 | procedure 289 | var 290 | UserInfo: TADSIUserInfo; 291 | begin 292 | Self.AddLog('Param.Domain = ' + edtDomain.Text); 293 | Self.AddLog('Param.UserName = ' + edtUserName.Text); 294 | 295 | {$REGION 'UserFind'} 296 | Self.AddLogValueAbortOnFail( 297 | 'UserFind', 298 | function: string 299 | var 300 | Resultado: Boolean; 301 | begin 302 | Resultado := ActiveDirectoryClient.GetUserInfo(edtDomain.Text, edtUserName.Text, UserInfo); 303 | Result := BoolToStr(Resultado, True); 304 | end 305 | ); 306 | {$ENDREGION} 307 | 308 | {$REGION 'UserActive'} 309 | Self.AddLogValueTry( 310 | 'UserActive', 311 | function: string 312 | var 313 | Resultado: Boolean; 314 | begin 315 | Resultado := ActiveDirectoryClient.GetUserActive(edtDomain.Text, edtUserName.Text); 316 | Result := BoolToStr(Resultado, True); 317 | end 318 | ); 319 | {$ENDREGION} 320 | 321 | Self.AddLogUserInfo(UserInfo); 322 | end 323 | ); 324 | end; 325 | 326 | procedure TfrmMain.btnAuthenticateClick(Sender: TObject); 327 | begin 328 | Self.AddLogSession( 329 | Sender, 330 | procedure 331 | begin 332 | Self.AddLog('Param.Domain = ' + edtDomain.Text); 333 | Self.AddLog('Param.UserName = ' + edtUserName.Text); 334 | Self.AddLog('Param.UserPass = ' + Self.GetPasswordLog); 335 | 336 | {$REGION 'Authenticated'} 337 | Self.AddLogValueTry( 338 | 'Authenticated', 339 | function: string 340 | var 341 | Resultado: Boolean; 342 | begin 343 | Resultado := ActiveDirectoryClient.AuthenticateUser(edtDomain.Text, edtUserName.Text, edtUserPass.Text); 344 | Result := BoolToStr(Resultado, True); 345 | end 346 | ); 347 | {$ENDREGION} 348 | end 349 | ); 350 | end; 351 | 352 | end. 353 | -------------------------------------------------------------------------------- /samples/samples.optset: -------------------------------------------------------------------------------- 1 |  2 | 3 | ..\..\..\out\$(Platform)\$(Config);$(DCC_UnitSearchPath) 4 | ..\..\..\out\$(Platform)\$(Config) 5 | ..\..\..\out\$(Platform)\$(Config) 6 | 7 | 8 | Delphi.Personality.12 9 | OptionSet 10 | 11 | 12 | 13 | 12 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/Core/ActiveDirectory.Client.Winapi.pas: -------------------------------------------------------------------------------- 1 | unit ActiveDirectory.Client.Winapi; 2 | 3 | interface 4 | 5 | uses 6 | ActiveDirectory.Client.Intf, 7 | ActiveDirectory.Types; 8 | 9 | type 10 | { Class implements Active Directory Client by WinApi } 11 | TActiveDirectoryClientWinapi = class(TInterfacedObject, IActiveDirectoryClient) 12 | private 13 | function GetActiveLDAPDomainName: string; 14 | 15 | protected 16 | function GetCurrentUserName: string; 17 | function GetCurrentDomainName(inUserName: string): string; 18 | function GetCurrentLDAPDomainName(inDomainName: string): string; 19 | function GetAllProviders: string; // CSV (LDAP, WinNT, ...) 20 | function GetActiveDirectoryEnabled: Boolean; 21 | 22 | function GetUserInfo(inDomainName, inUserName: string; out outUserInfo: TADSIUserInfo): Boolean; 23 | function GetUserActive(inDomainName, inUserName: string): Boolean; 24 | 25 | function AuthenticateUser(inDomainName, inUserName, inUserPass: string): Boolean; 26 | 27 | public 28 | class function New: IActiveDirectoryClient; 29 | end; 30 | 31 | implementation 32 | 33 | uses 34 | System.SysUtils, 35 | System.Classes, 36 | Winapi.Windows, 37 | Winapi.ActiveX, 38 | 39 | ActiveDirectory.Winapi.DllMapper, // <-- Generate by mapping dlls ADSI 40 | ActiveDirectory.Winapi.TLB; // <-- Generate by "Import Type Library" from "c:\windows\system32\activeds.tlb" (Active DS Type Library) 41 | 42 | const 43 | _ProviderAD_LDAP = 'LDAP:'; 44 | _ProviderAD_WinNT = 'WinNT:'; 45 | _ProviderAD_PathBegin = '//'; 46 | _ProviderAD_PathDelim = '/'; 47 | _CSV_Sep = ','; 48 | 49 | type 50 | { Class Utilities } 51 | TActiveDirectoryWinapiUtils = class 52 | private 53 | class var FUserInfoEmpty: TADSIUserInfo; 54 | public 55 | class procedure ClearUserInfo(var inUserInfo: TADSIUserInfo); 56 | 57 | class function GetPathLDAP(inDomainName: string; inObjName: string = ''): string; 58 | class function GetPathWinNT(inDomainName: string; inObjName: string = ''): string; 59 | end; 60 | 61 | { TActiveDirectoryWinapiUtils } 62 | 63 | class procedure TActiveDirectoryWinapiUtils.ClearUserInfo(var inUserInfo: TADSIUserInfo); 64 | begin 65 | inUserInfo := Self.FUserInfoEmpty; 66 | end; 67 | 68 | class function TActiveDirectoryWinapiUtils.GetPathLDAP(inDomainName: string; inObjName: string = ''): string; 69 | begin 70 | Result := _ProviderAD_LDAP + _ProviderAD_PathBegin + Trim(inDomainName); 71 | 72 | if (Trim(inObjName) <> '') then 73 | Result := Result + _ProviderAD_PathDelim + inObjName 74 | end; 75 | 76 | class function TActiveDirectoryWinapiUtils.GetPathWinNT(inDomainName: string; inObjName: string = ''): string; 77 | begin 78 | Result := _ProviderAD_WinNT + _ProviderAD_PathBegin + Trim(inDomainName); 79 | 80 | if (Trim(inObjName) <> '') then 81 | Result := Result + _ProviderAD_PathDelim + inObjName 82 | end; 83 | 84 | { TActiveDirectoryClientWinapi } 85 | 86 | class function TActiveDirectoryClientWinapi.New: IActiveDirectoryClient; 87 | begin 88 | Result := TActiveDirectoryClientWinapi.Create; 89 | end; 90 | 91 | function TActiveDirectoryClientWinapi.GetActiveLDAPDomainName: string; 92 | var 93 | UserName: string; 94 | DomainName: string; 95 | begin 96 | UserName := Self.GetCurrentUserName; 97 | DomainName := Self.GetCurrentDomainName(UserName); 98 | Result := Self.GetCurrentLDAPDomainName(DomainName); 99 | end; 100 | 101 | function TActiveDirectoryClientWinapi.GetCurrentUserName: string; 102 | const 103 | cnMaxUserNameLen = 254; 104 | var 105 | UserName: string; 106 | dwUserNameLen: DWord; 107 | begin 108 | dwUserNameLen := cnMaxUserNameLen - 1; 109 | SetLength(UserName, cnMaxUserNameLen); 110 | GetUserName(PChar(UserName), dwUserNameLen); 111 | SetLength(UserName, dwUserNameLen); 112 | Result := UserName; 113 | end; 114 | 115 | function TActiveDirectoryClientWinapi.GetCurrentDomainName(inUserName: string): string; 116 | const 117 | DNLEN = 255; 118 | var 119 | SId: PSID; 120 | SIdSize: DWord; 121 | SIdNameUse: DWord; 122 | DomainNameSize: DWord; 123 | DomainName: array [0 .. DNLEN] of char; 124 | begin 125 | Result := ''; 126 | 127 | SIdSize := 65536; 128 | GetMem(SId, SIdSize); 129 | try 130 | DomainNameSize := DNLEN + 1; 131 | SIdNameUse := SidTypeUser; 132 | 133 | if LookupAccountName(nil, PChar(inUserName), SId, SIdSize, DomainName, DomainNameSize, SIdNameUse) then 134 | Result := StrPas(DomainName); 135 | finally 136 | FreeMem(SId); 137 | end; 138 | end; 139 | 140 | function TActiveDirectoryClientWinapi.GetCurrentLDAPDomainName(inDomainName: string): string; 141 | var 142 | Path: string; 143 | Resultado: HRESULT; 144 | AD: IADs; 145 | begin 146 | Path := TActiveDirectoryWinapiUtils.GetPathLDAP(inDomainName); 147 | Resultado := ADsGetObject(Path, IADs, AD); 148 | 149 | if (Failed(Resultado)) then 150 | begin 151 | Result := ''; 152 | Exit; 153 | end; 154 | 155 | Result := AD.Get('distinguishedName'); 156 | end; 157 | 158 | function TActiveDirectoryClientWinapi.GetAllProviders: string; 159 | var 160 | NSContainer: IADsContainer; 161 | Item: IADs; 162 | Enum: IEnumVariant; 163 | Resultado: HRESULT; 164 | varArray: OleVariant; 165 | NumElements: ULONG; 166 | Value: string; 167 | Lista: TStringList; 168 | begin 169 | Lista := TStringList.Create; 170 | try 171 | NSContainer := nil; 172 | ADsGetObject('ADs:', IADsContainer, NSContainer); 173 | 174 | Enum := nil; 175 | Resultado := ADsBuildEnumerator(NSContainer, Enum); 176 | 177 | while SUCCEEDED(Resultado) do 178 | begin 179 | Resultado := ADsEnumerateNext(Enum, 1, varArray, NumElements); 180 | 181 | if (NumElements <= 0) then 182 | Break; 183 | 184 | IDispatch(varArray).QueryInterface(IADs, Item); 185 | Value := Item.ADsPath; 186 | 187 | // Add 188 | Lista.Add(Value); 189 | end; 190 | 191 | Lista.Delimiter := _CSV_Sep; 192 | Result := Lista.DelimitedText; 193 | finally 194 | FreeAndNil(Lista); 195 | end; 196 | end; 197 | 198 | function TActiveDirectoryClientWinapi.GetActiveDirectoryEnabled: Boolean; 199 | var 200 | LDAPDomain: string; 201 | Providers: string; 202 | begin 203 | try 204 | LDAPDomain := Self.GetActiveLDAPDomainName; 205 | Providers := Self.GetAllProviders; 206 | 207 | if (Trim(LDAPDomain) <> '') and (Pos(_ProviderAD_LDAP, Providers) > -1) then 208 | Result := True 209 | else 210 | Result := False; 211 | except 212 | Result := False; 213 | end; 214 | end; 215 | 216 | function TActiveDirectoryClientWinapi.GetUserInfo(inDomainName, inUserName: string; out outUserInfo: TADSIUserInfo): Boolean; 217 | var 218 | Path: string; 219 | Resultado: HRESULT; 220 | User: IAdsUser; 221 | Groups: IAdsMembers; 222 | Group: IAdsGroup; 223 | Enum: IEnumVariant; 224 | varGroup: OleVariant; 225 | UserFlags: Integer; 226 | Temp: LongWord; 227 | begin 228 | Result := False; 229 | TActiveDirectoryWinapiUtils.ClearUserInfo(outUserInfo); 230 | 231 | if (Trim(inDomainName) = '') then 232 | Exit; 233 | 234 | if (Trim(inUserName) = '') then 235 | Exit; 236 | 237 | Path := TActiveDirectoryWinapiUtils.GetPathWinNT(inDomainName, inUserName); 238 | Resultado := ADsGetObject(Path, IAdsUser, User); 239 | 240 | if (Failed(Resultado)) or (User = nil) then 241 | Exit; 242 | 243 | // Get user info 244 | UserFlags := User.Get('userFlags'); 245 | 246 | outUserInfo.UID := inUserName; 247 | outUserInfo.UserName := User.FullName; 248 | outUserInfo.Description := User.Description; 249 | outUserInfo.Password.Expired := User.Get('PasswordExpired'); 250 | outUserInfo.Password.CannotChange := (UserFlags and ADS_UF_PASSWD_CANT_CHANGE) <> 0; 251 | outUserInfo.Password.NeverExpires := (UserFlags and ADS_UF_DONT_EXPIRE_PASSWD) <> 0; 252 | outUserInfo.Disabled := User.AccountDisabled; 253 | outUserInfo.LockedOut := User.IsAccountLocked; 254 | 255 | // Get all groups by user in CSV (group1, group2, ...) 256 | outUserInfo.Groups := ''; 257 | 258 | Groups := User.Groups; 259 | Enum := (Groups._NewEnum as IEnumVariant); 260 | 261 | if (Enum <> nil) then 262 | begin 263 | while (Enum.Next(1, varGroup, Temp) = S_OK) do 264 | begin 265 | Group := (IDispatch(varGroup) as IAdsGroup); 266 | 267 | if (outUserInfo.Groups <> '') then 268 | outUserInfo.Groups := outUserInfo.Groups + _CSV_Sep; 269 | 270 | outUserInfo.Groups := outUserInfo.Groups + Group.Name; 271 | 272 | VariantClear(varGroup); 273 | end; 274 | end; 275 | 276 | User := nil; 277 | Result := True; 278 | end; 279 | 280 | function TActiveDirectoryClientWinapi.GetUserActive(inDomainName, inUserName: string): Boolean; 281 | var 282 | UserInfo: TADSIUserInfo; 283 | UserFind: Boolean; 284 | begin 285 | Result := False; 286 | 287 | UserFind := Self.GetUserInfo(inDomainName, inUserName, UserInfo); 288 | 289 | if (not UserFind) then // User not found 290 | Exit; 291 | 292 | if (UserInfo.Disabled) then // User disabled 293 | Exit; 294 | 295 | if (UserInfo.LockedOut) then // User lockedout 296 | Exit; 297 | 298 | Result := True; 299 | end; 300 | 301 | function TActiveDirectoryClientWinapi.AuthenticateUser(inDomainName, inUserName, inUserPass: string): Boolean; 302 | var 303 | Path: string; 304 | Resultado: HRESULT; 305 | Obj: IADs; 306 | begin 307 | Result := False; 308 | 309 | if (Trim(inDomainName) = '') then 310 | Exit; 311 | 312 | if (Trim(inUserName) = '') then 313 | Exit; 314 | 315 | Path := TActiveDirectoryWinapiUtils.GetPathLDAP(inDomainName); 316 | Resultado := ADsOpenObject(Path, inUserName, inUserPass, ADS_SECURE_AUTHENTICATION, IADs, Obj); 317 | 318 | if (Failed(Resultado)) or (Obj = nil) then 319 | Exit; 320 | 321 | Obj := nil; 322 | Result := True; 323 | end; 324 | 325 | end. 326 | -------------------------------------------------------------------------------- /src/Core/ActiveDirectory.Client.pas: -------------------------------------------------------------------------------- 1 | unit ActiveDirectory.Client; 2 | 3 | interface 4 | 5 | uses 6 | ActiveDirectory.Client.Intf; 7 | 8 | { Singleton } 9 | function ActiveDirectoryClient: IActiveDirectoryClient; 10 | 11 | implementation 12 | 13 | uses 14 | ActiveDirectory.Client.Winapi; 15 | 16 | var 17 | FActiveDirectoryClient: IActiveDirectoryClient = nil; 18 | 19 | function ActiveDirectoryClient: IActiveDirectoryClient; 20 | begin 21 | if (not Assigned(FActiveDirectoryClient)) then 22 | FActiveDirectoryClient := TActiveDirectoryClientWinapi.New; 23 | 24 | Result := FActiveDirectoryClient; 25 | end; 26 | 27 | end. 28 | -------------------------------------------------------------------------------- /src/Core/ActiveDirectory.Types.pas: -------------------------------------------------------------------------------- 1 | unit ActiveDirectory.Types; 2 | 3 | interface 4 | 5 | type 6 | { Password by ADSI } 7 | TADSIPassword = record 8 | Expired: Boolean; 9 | NeverExpires: Boolean; 10 | CannotChange: Boolean; 11 | end; 12 | 13 | { User by ADSI } 14 | TADSIUserInfo = record 15 | UID: string; 16 | UserName: string; 17 | Description: string; 18 | Password: TADSIPassword; 19 | Disabled: Boolean; 20 | LockedOut: Boolean; 21 | Groups: string; // CSV (group1, group2, ...) 22 | end; 23 | 24 | implementation 25 | 26 | end. 27 | -------------------------------------------------------------------------------- /src/D210-XE7/ActiveDirectory4Delphi.dpk: -------------------------------------------------------------------------------- 1 | package ActiveDirectory4Delphi; 2 | 3 | {$R *.res} 4 | {$IFDEF IMPLICITBUILDING This IFDEF should not be used by users} 5 | {$ALIGN 8} 6 | {$ASSERTIONS ON} 7 | {$BOOLEVAL OFF} 8 | {$DEBUGINFO OFF} 9 | {$EXTENDEDSYNTAX ON} 10 | {$IMPORTEDDATA ON} 11 | {$IOCHECKS ON} 12 | {$LOCALSYMBOLS ON} 13 | {$LONGSTRINGS ON} 14 | {$OPENSTRINGS ON} 15 | {$OPTIMIZATION OFF} 16 | {$OVERFLOWCHECKS OFF} 17 | {$RANGECHECKS OFF} 18 | {$REFERENCEINFO ON} 19 | {$SAFEDIVIDE OFF} 20 | {$STACKFRAMES ON} 21 | {$TYPEDADDRESS OFF} 22 | {$VARSTRINGCHECKS ON} 23 | {$WRITEABLECONST OFF} 24 | {$MINENUMSIZE 1} 25 | {$IMAGEBASE $400000} 26 | {$DEFINE DEBUG} 27 | {$ENDIF IMPLICITBUILDING} 28 | {$DESCRIPTION 'Active Directory 4 Delphi'} 29 | {$IMPLICITBUILD ON} 30 | 31 | requires 32 | rtl, 33 | vcl; 34 | 35 | contains 36 | ActiveDirectory.Winapi.TLB in '..\Winapi\ActiveDirectory.Winapi.TLB.pas', 37 | ActiveDirectory.Winapi.DllMapper in '..\Winapi\ActiveDirectory.Winapi.DllMapper.pas', 38 | ActiveDirectory.Client.Intf in '..\Interfaces\ActiveDirectory.Client.Intf.pas', 39 | ActiveDirectory.Types in '..\Core\ActiveDirectory.Types.pas', 40 | ActiveDirectory.Client in '..\Core\ActiveDirectory.Client.pas', 41 | ActiveDirectory.Client.Winapi in '..\Core\ActiveDirectory.Client.Winapi.pas'; 42 | 43 | end. 44 | -------------------------------------------------------------------------------- /src/D210-XE7/ActiveDirectory4Delphi.dproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | {BFF1BEB7-1767-4894-BAD0-C8C3C68CC914} 4 | ActiveDirectory4Delphi.dpk 5 | 16.0 6 | VCL 7 | True 8 | Debug 9 | Win32 10 | 3 11 | Package 12 | 13 | 14 | true 15 | 16 | 17 | true 18 | Base 19 | true 20 | 21 | 22 | true 23 | Base 24 | true 25 | 26 | 27 | true 28 | Base 29 | true 30 | 31 | 32 | true 33 | Base 34 | true 35 | 36 | 37 | true 38 | Base 39 | true 40 | 41 | 42 | true 43 | Base 44 | true 45 | 46 | 47 | true 48 | Cfg_1 49 | true 50 | true 51 | 52 | 53 | true 54 | Base 55 | true 56 | 57 | 58 | true 59 | Cfg_2 60 | true 61 | true 62 | 63 | 64 | 65 | ActiveDirectory4Delphi 66 | System;Xml;Data;Datasnap;Web;Soap;Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;$(DCC_Namespace) 67 | true 68 | CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= 69 | true 70 | 3082 71 | false 72 | false 73 | false 74 | false 75 | false 76 | ..\source.optset 77 | 78 | 79 | None 80 | 81 | 82 | None 83 | 84 | 85 | None 86 | 87 | 88 | Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) 89 | None 90 | true 91 | Active Directory 4 Delphi 92 | 1033 93 | 94 | 95 | Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;$(DCC_Namespace) 96 | true 97 | 1033 98 | 99 | 100 | DEBUG;$(DCC_Define) 101 | true 102 | false 103 | true 104 | true 105 | true 106 | 107 | 108 | true 109 | 1033 110 | false 111 | 112 | 113 | false 114 | RELEASE;$(DCC_Define) 115 | 0 116 | 0 117 | 118 | 119 | true 120 | 1033 121 | 122 | 123 | 124 | 125 | MainSource 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | Cfg_2 137 | Base 138 | 139 | 140 | Base 141 | ..\source.optset 142 | 143 | 144 | Cfg_1 145 | Base 146 | 147 | 148 | 149 | Delphi.Personality.12 150 | Package 151 | 152 | 153 | 154 | ActiveDirectory4Delphi.dpk 155 | 156 | 157 | Microsoft Office 2000 Sample Automation Server Wrapper Components 158 | Microsoft Office XP Sample Automation Server Wrapper Components 159 | 160 | 161 | 162 | 163 | 164 | true 165 | 166 | 167 | true 168 | 169 | 170 | 171 | 172 | ActiveDirectory4Delphi.bpl 173 | true 174 | 175 | 176 | 177 | 178 | 1 179 | .dylib 180 | 181 | 182 | 0 183 | .bpl 184 | 185 | 186 | 1 187 | .dylib 188 | 189 | 190 | 1 191 | .dylib 192 | 193 | 194 | 195 | 196 | 1 197 | .dylib 198 | 199 | 200 | 0 201 | .dll;.bpl 202 | 203 | 204 | 205 | 206 | 1 207 | 208 | 209 | 1 210 | 211 | 212 | 213 | 214 | 215 | ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 216 | 1 217 | 218 | 219 | 220 | 221 | res\drawable-normal 222 | 1 223 | 224 | 225 | 226 | 227 | library\lib\x86 228 | 1 229 | 230 | 231 | 232 | 233 | 1 234 | 235 | 236 | 1 237 | 238 | 239 | 240 | 241 | 242 | library\lib\armeabi-v7a 243 | 1 244 | 245 | 246 | 247 | 248 | 1 249 | 250 | 251 | 1 252 | 253 | 254 | 255 | 256 | res\drawable-xlarge 257 | 1 258 | 259 | 260 | 261 | 262 | res\drawable-xhdpi 263 | 1 264 | 265 | 266 | 267 | 268 | 1 269 | 270 | 271 | 1 272 | 273 | 274 | 275 | 276 | res\drawable-xxhdpi 277 | 1 278 | 279 | 280 | 281 | 282 | library\lib\mips 283 | 1 284 | 285 | 286 | 287 | 288 | res\drawable 289 | 1 290 | 291 | 292 | 293 | 294 | 1 295 | 296 | 297 | 1 298 | 299 | 300 | 0 301 | 302 | 303 | 304 | 305 | 1 306 | .framework 307 | 308 | 309 | 0 310 | 311 | 312 | 313 | 314 | res\drawable-small 315 | 1 316 | 317 | 318 | 319 | 320 | 321 | 1 322 | 323 | 324 | Contents\MacOS 325 | 0 326 | 327 | 328 | 329 | 330 | classes 331 | 1 332 | 333 | 334 | 335 | 336 | 337 | 1 338 | 339 | 340 | 1 341 | 342 | 343 | 344 | 345 | res\drawable 346 | 1 347 | 348 | 349 | 350 | 351 | Contents\Resources 352 | 1 353 | 354 | 355 | 356 | 357 | 358 | 1 359 | 360 | 361 | 1 362 | 363 | 364 | 365 | 366 | 1 367 | 368 | 369 | library\lib\armeabi-v7a 370 | 1 371 | 372 | 373 | 0 374 | 375 | 376 | 1 377 | 378 | 379 | 1 380 | 381 | 382 | 383 | 384 | library\lib\armeabi 385 | 1 386 | 387 | 388 | 389 | 390 | res\drawable-large 391 | 1 392 | 393 | 394 | 395 | 396 | 0 397 | 398 | 399 | 0 400 | 401 | 402 | 0 403 | 404 | 405 | 0 406 | 407 | 408 | 0 409 | 410 | 411 | 412 | 413 | 1 414 | 415 | 416 | 1 417 | 418 | 419 | 420 | 421 | res\drawable-ldpi 422 | 1 423 | 424 | 425 | 426 | 427 | res\values 428 | 1 429 | 430 | 431 | 432 | 433 | 1 434 | 435 | 436 | 1 437 | 438 | 439 | 440 | 441 | res\drawable-mdpi 442 | 1 443 | 444 | 445 | 446 | 447 | res\drawable-hdpi 448 | 1 449 | 450 | 451 | 452 | 453 | 1 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | False 465 | False 466 | False 467 | False 468 | True 469 | True 470 | 471 | 472 | 12 473 | 474 | 475 | 476 | 477 | 478 | -------------------------------------------------------------------------------- /src/D210-XE7/ActiveDirectory4Delphi.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EdZava/VCL-ActiveDirectory4Delphi/2908d2c8a61e3714a24688d20c2ce9ad4db6a13e/src/D210-XE7/ActiveDirectory4Delphi.res -------------------------------------------------------------------------------- /src/Interfaces/ActiveDirectory.Client.Intf.pas: -------------------------------------------------------------------------------- 1 | unit ActiveDirectory.Client.Intf; 2 | 3 | interface 4 | 5 | uses 6 | ActiveDirectory.Types; 7 | 8 | type 9 | IActiveDirectoryClient = interface 10 | ['{9F8FCA96-35A7-4B36-8406-0CAD9CF6ADED}'] 11 | function GetCurrentUserName: string; 12 | function GetCurrentDomainName(inUserName: string): string; 13 | function GetCurrentLDAPDomainName(inDomainName: string): string; 14 | function GetAllProviders: string; // CSV (LDAP, WinNT, ...) 15 | function GetActiveDirectoryEnabled: Boolean; 16 | 17 | function GetUserInfo(inDomainName, inUserName: string; out outUserInfo: TADSIUserInfo): Boolean; 18 | function GetUserActive(inDomainName, inUserName: string): Boolean; 19 | 20 | function AuthenticateUser(inDomainName, inUserName, inUserPass: string): Boolean; 21 | end; 22 | 23 | implementation 24 | 25 | end. 26 | -------------------------------------------------------------------------------- /src/Winapi/ActiveDirectory.Winapi.DllMapper.pas: -------------------------------------------------------------------------------- 1 | unit ActiveDirectory.Winapi.DllMapper; 2 | 3 | interface 4 | 5 | uses 6 | System.SysUtils, 7 | System.Variants, 8 | Winapi.Windows, 9 | Winapi.ActiveX, 10 | 11 | ActiveDirectory.Winapi.TLB; 12 | 13 | const 14 | S_ADS_NOMORE_ROWS = $00005012; 15 | MAX_ADS_ENUM_COUNT = 100; 16 | 17 | type 18 | { Helpers } 19 | 20 | TADsEnumCallBack = procedure(disp: IADs) of object; 21 | 22 | function GetObject(Path: string): IDispatch; 23 | procedure ADsEnumerateObjects(const Path: string; Func: TADsEnumCallBack); overload; 24 | procedure ADsEnumerateObjects(Container: IADsContainer; Func: TADsEnumCallBack); overload; 25 | procedure ADsEnumerateMembers(Members: IADsMembers; Func: TADsEnumCallBack); 26 | 27 | { Mapers API ADSI } 28 | 29 | function ADsGetObject(lpszPathName: WideString; const riid: TGUID; out ppObject): HRESULT; safecall; 30 | 31 | function ADsBuildEnumerator(const pADsContainer: IADsContainer; out ppEnumVariant: IEnumVARIANT): HRESULT; safecall; 32 | 33 | function ADsFreeEnumerator(pEnumVariant: IEnumVARIANT): HRESULT; safecall; 34 | function ADsEnumerateNext(pEnumVariant: IEnumVARIANT; 35 | cElements: ULONG; 36 | var pvar: OleVARIANT; 37 | var pcElementsFetched: ULONG): HRESULT; safecall; 38 | 39 | function ADsBuildVarArrayStr(lppPathNames: PWideChar; 40 | dwPathNames: DWORD; 41 | var pvar: VARIANT): HRESULT; safecall; 42 | 43 | function ADsBuildVarArrayInt(lpdwObjectTypes: LPDWORD; 44 | dwObjectTypes: DWORD; 45 | var pvar: VARIANT): HRESULT; safecall; 46 | 47 | function ADsOpenObject(lpszPathName: WideString; 48 | lpszUserName: WideString; 49 | lpszPassword: WideString; 50 | dwReserved: DWORD; 51 | const riid: TGUID; 52 | out ppObject): HRESULT; safecall; 53 | 54 | function ADsGetLastError(var pError: DWORD; 55 | lpErrorBuf: PWideChar; 56 | dwErrorBufLen: DWORD; 57 | lpNameBuf: PWideChar; 58 | dwNameBufLen: DWORD): HRESULT; stdcall; 59 | 60 | procedure ADsSetLastError(dwErr: DWORD; pszErro, pszProvider: LPWSTR); stdcall; 61 | 62 | procedure AllocADsMem(cb: DWORD); stdcall; 63 | 64 | function FreeADsMem(pMem: Pointer): BOOL; stdcall; 65 | 66 | function ReallocADsMem(pOldMem: Pointer; cbOld, cbNew: DWORD): Pointer; stdcall; 67 | 68 | function AllocADsStr(pStr: LPWSTR): LPWSTR; stdcall; 69 | 70 | function FreeADsStr(pStr: LPWSTR): BOOL; stdcall; 71 | 72 | function ReallocADsStr(ppStr: LPWSTR; pStr: LPWSTR): BOOL; stdcall; 73 | 74 | function ADsEncodeBinaryData(pbSrcData: PBYTE; dwSrcLen: DWORD; ppszDestData: LPWSTR): HRESULT; stdcall; 75 | 76 | function PropVariantToAdsType(pVariant: VARIANT; 77 | dwNumVariant: DWORD; 78 | ppAdsValues: Pointer; 79 | pdwNumValues: PDWORD 80 | ): HRESULT; stdcall; 81 | 82 | function AdsTypeToPropVariant( 83 | pAdsValues: Pointer; 84 | dwNumValues: DWORD; 85 | pVariant: VARIANT 86 | ): HRESULT; stdcall; 87 | 88 | procedure AdsFreeAdsValues(pAdsValues: Pointer; dwNumValues: DWORD); stdcall; 89 | 90 | implementation 91 | 92 | const 93 | ADSI = 'activeds.dll'; 94 | ADSLDPC = 'adsldpc.dll'; 95 | 96 | function GetObject(Path: string): IDispatch; 97 | begin 98 | ADsGetObject(Path, IDispatch, Result); 99 | end; 100 | 101 | procedure ADsEnumerateObjects(Container: IADsContainer; Func: TADsEnumCallBack); 102 | var 103 | e: IEnumVARIANT; 104 | varArr: OleVARIANT; 105 | lNumElements: ULONG; 106 | obj: IADs; 107 | hr: integer; 108 | begin 109 | hr := ADsBuildEnumerator(Container, e); 110 | while (Succeeded(hr)) do 111 | begin 112 | hr := ADsEnumerateNext(e, 1, 113 | varArr, lNumElements); 114 | 115 | if (lNumElements = 0) then 116 | break; 117 | 118 | IDispatch(varArr).QueryInterface(IADs, obj); 119 | if obj <> nil then 120 | begin 121 | Func(obj); 122 | end; 123 | varArr := NULL; 124 | end; 125 | end; 126 | 127 | procedure ADsEnumerateObjects(const Path: string; Func: TADsEnumCallBack); 128 | var 129 | x: IADsContainer; 130 | begin 131 | try 132 | ADsGetObject(Path, IADsContainer, x); 133 | except 134 | raise Exception.Create('IADsContainer not supported'); 135 | end; 136 | ADsEnumerateObjects(x, Func); 137 | end; 138 | 139 | procedure ADsEnumerateMembers(Members: IADsMembers; Func: TADsEnumCallBack); 140 | var 141 | e: IEnumVARIANT; 142 | varArr: OleVARIANT; 143 | lNumElements: ULONG; 144 | obj: IADs; 145 | hr: integer; 146 | begin 147 | hr := S_OK; 148 | e := Members._NewEnum as IEnumVARIANT; 149 | while (Succeeded(hr)) do 150 | begin 151 | hr := ADsEnumerateNext(e, 1, 152 | varArr, lNumElements); 153 | 154 | if (lNumElements = 0) then 155 | break; 156 | 157 | IDispatch(varArr).QueryInterface(IADs, obj); 158 | if obj <> nil then 159 | begin 160 | Func(obj); 161 | end; 162 | varArr := NULL; 163 | end; 164 | end; 165 | 166 | function ADsGetObject; external ADSI; 167 | function ADsBuildEnumerator; external ADSI; 168 | function ADsEnumerateNext; external ADSI; 169 | function ADsFreeEnumerator; external ADSI; 170 | function ADsBuildVarArrayStr; external ADSI; 171 | function ADsBuildVarArrayInt; external ADSI; 172 | function ADsOpenObject; external ADSI; 173 | function PropVariantToAdsType; external ADSI; 174 | function AdsTypeToPropVariant; external ADSI; 175 | procedure AdsFreeAdsValues; external ADSI; 176 | 177 | function ADsGetLastError; external ADSLDPC name 'ADsGetLastError'; 178 | procedure ADsSetLastError; external ADSLDPC name 'ADsSetLastError'; 179 | procedure AllocADsMem; external ADSLDPC name 'AllocADsMem'; 180 | function FreeADsMem; external ADSLDPC name 'FreeADsMem'; 181 | function ReallocADsMem; external ADSLDPC name 'ReallocADsMem'; 182 | function AllocADsStr; external ADSLDPC name 'AllocADsStr'; 183 | function FreeADsStr; external ADSLDPC name 'FreeADsStr'; 184 | function ReallocADsStr; external ADSLDPC name 'ReallocADsStr'; 185 | function ADsEncodeBinaryData; external ADSLDPC name 'ADsEncodeBinaryData'; 186 | 187 | end. 188 | -------------------------------------------------------------------------------- /src/source.optset: -------------------------------------------------------------------------------- 1 |  2 | 3 | ..\..\out\$(Platform)\$(Config) 4 | ..\..\out\$(Platform)\$(Config) 5 | 6 | 7 | Delphi.Personality.12 8 | OptionSet 9 | 10 | 11 | 12 | 12 13 | 14 | 15 | --------------------------------------------------------------------------------