Jump to content

Lars Fosdal

Administrators
  • Content Count

    3323
  • Joined

  • Last visited

  • Days Won

    110

Everything posted by Lars Fosdal

  1. Lars Fosdal

    NetGroupGetUsers strange errors on Win64 on buffered reads

    Check out unit web.win.AdsTypes: Here is some code I wrote to find out if a user had an AD membership. unit ActiveDSUtil; /// Written by Lars Fosdal, 16 DEC 2014 /// Note that calling AD functions is slow. interface uses Classes, SysUtils, ActiveX, ActiveDS_tlb, web.win.adstypes; type TADGroupList = array of String; TAnonParamFunc<TA,TR> = reference to function (const v:TA):TR; /// <summary> Enumerates the group memberships of an AD user </summary> function EnumADUserGroupMemberships(const aDomain, aUser: String; EnumHandler: TAnonParamFunc<IAdsGroup, Boolean>):Boolean; /// <summary> Returns a list of all AD groups for an AD user </summary> function GetADUserGroupMemberships(const aDomain, aUser: String):TStringList; /// <summary> Checks if an AD user is member of one or more specific groups</summary> function UserHasADGroupMembership(const aDomain, aUser: String; const GroupList: TAdGroupList): Boolean; implementation function EnumADUserGroupMemberships(const aDomain, aUser: String; EnumHandler: TAnonParamFunc<IADsGroup, Boolean>):Boolean; var hr: HREsult; User: IADsUser; Enum: IEnumVariant; varGroup: OleVariant; EnumHelper: LongWord; begin Result := False; CoInitialize(nil); try hr := ADsGetObject('WinNT://'+aDomain+'/'+aUser+',user',IID_IADsUser3 , User); if not Failed(hr) then begin try Enum := User.Groups._NewEnum as IEnumVariant; while Assigned(Enum) and (Enum.Next(1, varGroup, EnumHelper) = S_OK) do begin try if EnumHandler(IDispatch(varGroup) as IADsGroup) then EXIT(True); finally VariantClear(varGroup); end; end; finally User := nil; end; end; finally CoUninitialize; end; end; function GetADUserGroupMemberships(const aDomain, aUser: String):TStringList; var List: TStringList; begin List := TStringList.Create; List.BeginUpdate; try EnumADUserGroupMemberships(aDomain, aUser, function(const Group: IAdsGroup):Boolean begin Result := False; List.Add(Group.Name + ' ' + Group.Class_); end); finally List.Sort; List.Insert(0, aDomain +'\'+ aUser); List.EndUpdate; Result := List; end; end; function UserHasADGroupMembership(const aDomain, aUser: String; const GroupList: TAdGroupList): Boolean; begin Result := EnumADUserGroupMemberships(aDomain, aUser, function(const Group: IAdsGroup):Boolean var GroupName: String; begin Result := False; for GroupName in GroupList do begin Result := CompareText(GroupName, Group.Name) = 0; if Result then Break; // Return true for first match end; end); end; end.
  2. Lars Fosdal

    NetGroupGetUsers strange errors on Win64 on buffered reads

    @Davide Angeli - BTW- Why don't you use the AD APIs instead?
  3. Lars Fosdal

    NetGroupGetUsers strange errors on Win64 on buffered reads

    Windows 10, 64-bit Compile to 32-bit target - runs as expected Compile to 64-bit target - unable to create process
  4. Lars Fosdal

    TEdgeBrowser : "Unsafe attempt to load URL"

    I'd complain loudly to the company that wrote that app. These folders have been forbidden for the last 15 years - at least. Dynamic data should go to user folders for user specific data, or AppData for system wide data.
  5. Lars Fosdal

    TEdgeBrowser : "Unsafe attempt to load URL"

    It was an possibly premature assumption from my side...
  6. You sort of posted the answer with your question. Not sure what you are trying to improve?
  7. Lars Fosdal

    TEdgeBrowser : "Unsafe attempt to load URL"

    Putting writable files under C:\Program Files is a very bad idea, but probably not related to the errors. You could in theory have your own built in web server and serve the files from there to avoid direct file system access from the browser? Comment #3 here is a possible explanation. https://bugs.chromium.org/p/chromium/issues/detail?id=512542#c3
  8. Lars Fosdal

    PowerBuilder Code Covert to Delphi

    I'd forgo all PowerBuilder UI related things and focus on the function of the app - what does it need to do. Analyse the code (a "screen" here is a reference to a window or combination of windows/controls) - how do you navigate it - what does each screen do - where does it get its data - how does it treat and display the data - what can you do within that screen You would only need to focus on bringing the content and functionality over, without dwelling too much on the old-school PowerBuilder UI code. It would be more of a rewrite than a migration.
  9. Please post in English (use Google translate if necessary).
  10. Lars Fosdal

    Replacing Apostrophe

    So, TNetEncoding.HTML.Decode needs to be updated to support HTML5... Edit: Looks like a significant expansion of named entities. HTML5: https://www.w3.org/TR/2011/WD-html5-20110525/named-character-references.html HTML4: https://www.w3.org/TR/html4/sgml/entities.html
  11. Lars Fosdal

    Replacing Apostrophe

    Nope. https://stackoverflow.com/questions/2083754/why-shouldnt-apos-be-used-to-escape-single-quotes
  12. Lars Fosdal

    Windows 11 22H2 lost batch file association

    https://www.educba.com/cmd-vs-bat/
  13. Lars Fosdal

    Windows 11 22H2 lost batch file association

    .bat is pretty stoneage. .cmd has replaced it. unless you go for PowerShell, which is .ps1 (I absolutely love PS)
  14. Lars Fosdal

    Replacing Apostrophe

    AnsiReplaceStr( cLast, '&#39;', '' ); Is that an empty string or is it the forum software that plays tricks on us? It should look like AnsiReplaceStr( cLast, '&#39;', '''' );
  15. That's an estimate based on when the average time before the warranty on a laptop runs out and updates are no longer provided 😛
  16. Lars Fosdal

    XML validation

    The GIGO rule applies. Garbage in -> Garbage out. Hence, clean up your data by doing your validation during input.
  17. Lars Fosdal

    Change of coding style/structure..

    I go out of my way to avoid using with. Why would you need to explicitly set a local variable nil? One that just has been free'd and is about to be non-existent?
  18. Lars Fosdal

    XML validation

    Do you want to do it in the generating app, or do you want to check the XML by validating against a schema (xsd)? Personally, I would have done it in Delphi. So much faster and a lot less trouble.
  19. Lars Fosdal

    How can i display skew t and hodograph plots

    You can feed data to Python, do the calculations in Python, get the data points back to Delphi and then feed them to TChart. It is rare that you find ready-made code that does what you want. Most of the time you must do the work yourself.
  20. Lars Fosdal

    11.2 Patch 1 is out

    For less "redirections": https://blogs.embarcadero.com/rad-studio-11-2-alexandria-patch-1-available/
  21. Lars Fosdal

    11.2 Patch 1 is out

    The patch appears in GetIt and you get a reminder on the welcome page?
  22. Lars Fosdal

    Luna Game Toolkit

    Facebook 😞
  23. Lars Fosdal

    Delphi 11.2 Patch 1 bug ??

    Is it reproduceable if you make a new project from scratch? If it is - register the problem on the quality site.
  24. Design wise, it depends a lot on whether your app can keep working while progress is ongoing or not. In some places - I just keep a panel hidden on top of the main window and expand it when I need to alert the user to why the app is blocking/busy. The content of that can be messages, a checklist, or a progress bar. Here a launch message "Forbereder oppstart av TineAdmin for Brummundal Test" (Preparing startup of Tine Admin for ...) after the user clicked the TineAdmin icon on the toolbar. This app is a little bit unusual as it doesn't have a main menu - but when it does - and I am blocking - I disable and update it. The benefit of using a panel is that it doesn't interfere with the window functionality when it the operation is non blocking. In other cases, I have a floating window on top with some messages. Here for login progress (Checking version)
  25. I like these messages that some use instead of a progress bar. A progress bar is linear - while the messages don't necessarily imply a linear time flow. Getting started Putting the ducks in a row Cleanup on isle four Seeing our target Just one more thing We have arrived
×