How can I replace dependence on wldap32.dll for LDAPsend of Synapse?

Anonymous
2016-01-29
2016-05-20
  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous - 2016-01-29

    Attempting to replace dependence on MS Windows DLLs and overwrite parts of the code.
    The following piece of code of procedure TLDAPSession.Search not working properly, how do I correctly fill the data into TLdapEntryList? It does not affect the value of an attribute. The result of the function (plmSearch) ldap_search_s is type TLDAPsend.

    ~~~~
    procedure TLDAPSession.Search(const Filter, Base: string; const Scope: Cardinal; attrs: PCharArray; const NoValues: LongBool; Result: TLdapEntryList; SearchProc: TSearchCallback = nil);
    var
    plmSearch: TLDAPsend;
    plmEntry: TLDAPResult;
    pszdn: string;
    i,j : integer;
    Attr: TLdapAttribute;
    pszAttr: string;
    Entry: TLdapEntry;

    begin
    if not fPagedSearch then
    begin
    Err := ldap_search_s(pld, PChar(Base), Scope, PChar(Filter), PChar(attrs), Ord(NoValues), plmSearch);

       // entry
      for i:=0 to plmSearch.SearchResult.Count -1 do
      begin
         pszdn:= plmSearch.SearchResult[i].ObjectName;
         Entry := TLdapEntry.Create(Self, pszdn);
         //Result.Add(Entry);
         if not NoValues then
         begin
           Entry.fState := [esReading];
          try
             // attributes
             for j := 0 to plmSearch.SearchResult[i].Attributes.Count - 1 do
             begin
                pszAttr := plmSearch.SearchResult[i].Attributes[j].AttributeName;
                pszdn   := plmSearch.SearchResult[i].Attributes.Get(pszAttr);
    
                Attr := Entry.Attributes.Add(pszAttr);
                Attr.fState := Attr.fState + [asBrowse];
    
                Attr.AddValue(pszdn);
    
             end;
             Entry.fState := Entry.fState + [esBrowse];
          finally
             Entry.fState := Entry.fState - [esReading];
           end;
        end;
        Result.Add(Entry);
     end;
    

    end;
    ~~~~

     
  • Tihomir Karlovic

    Sorry for a delay, I was too bussy last month, didn't even see your message... did you solve the problem or do you still need assistance? Pleas let me know.

    Cheers,
    Tihomir

     
    • Comment has been marked as spam. 
      Undo

      You can see all pending comments posted by this user  here

      Anonymous - 2016-04-06

      Yes I solve the problem with code:

      unit LDAPClasses;
      
      uses
       ....,
        LinLDAP, LDAPSend
      
      ....
      
      procedure TLdapSession.ProcessSearchEntry(const plmEntry: TLDAPResult; Attributes: TLdapAttributeList);
      var
        Attr: TLdapAttribute;
        i,j: Integer;
        pszAttr:string;
        pszdn: string;
      
      begin
        for i := 0 to plmEntry.Attributes.Count - 1 do
        begin
              pszAttr := plmEntry.Attributes[i].AttributeName;
              Attr := Attributes.Add(pszAttr);
              Attr.fState := Attr.fState + [asBrowse];
              for j:=0 to plmEntry.Attributes[i].Count-1 do
              begin
                pszdn:= trim(plmEntry.Attributes[i][j]);
                Attr.AddValue(pszdn);
              end;
        end;
      end;
      

      Regards
      Ivo

       
  • Tihomir Karlovic

    Hi Ivo,

    actually, there is not much WinAPI code in LDAPClasses. It would probably be easier to replace CharNext and MultiByteToWideChar functions with Linux equivalents, since those are the only WinAPI functions in LDAPClasses.pas :-)
    Anyway, I’m interested in your results, if you care to share that. I wanted to do a port to Linux myself but the lack of time prevented me so far. Did you actually manage to compile it for Linux?

    Cheers,
    Tihomir

     
    • Comment has been marked as spam. 
      Undo

      You can see all pending comments posted by this user  here

      Anonymous - 2016-04-14

      Hi Tihomir,

      Yes, I have a version for Linux, compiler Lazarus 1.6, Mageia Linux 5.
      Partially functional:
      - Browsing LDAP directories (OpenLDAP)
      - Schema browsing
      - LDIF export
      - LDIF import (solved yet function ldap_add_s)

      I would like to copy the source code on GitHub,
      but still not fully functional pre-alpha version,
      maybe in a few days (weeks?)

      Regards
      Ivo

      From the Internet

      {$IFDEF FPC}
      function CharNext(lpsz: PChar): PChar; 
      begin
        result := lpsz;
        if lpsz = #0 then exit;
        result := lpsz + 1;
      end;
      {$ENDIF}  
      
      function StringToWide(const S: AnsiString): WideString;
      var
        n: integer;
        x, y: integer;
      begin
        SetLength(Result, Length(S) div 2);
        for n := 1 to Length(S) div 2 do
        begin
          x := Ord(S[((n-1) * 2) + 1]);
          y := Ord(S[((n-1) * 2) + 2]);
          Result[n] := WideChar(x * 256 + y);
        end;
      end;
      
      function UTF8ToStringLen(const src: PAnsiChar; const Len: Integer): widestring; 
      var
        l: Integer;
      begin
        SetLength(Result, Len);
        if Len > 0 then
        begin
             Result:=UTF8ToAnsi(UTF8Copy(src,1,len));
        end;  
      end
      
      function StringToUTF8Len(const src: PChar; const Len: Integer): AnsiString;
      begin
        if Len > 0 then
        begin
         Result:=UTF8Copy(src,1,len);
        end
        else
          result:='';
      end
      
      function WideStringToUtf8Len(const src: PWideChar; const Len: Integer): AnsiString;
      begin
       Result:=UTF8Copy(src,1,len); 
      end
      
      LDAPClasses.pas
      in function TLDapAttributeData.GetType: TDataType;
      ...  if IsText(PAnsiChar(Data)) 
      
       
  • Tihomir Karlovic

    Well this is very exciting! I'm currently porting an LDAP Admin source code to the Delphi XT compiler (wide strings). I'd love to see what you did, perhaps we can join some efforts.

    Cheers,
    Tihomir

     
    • Comment has been marked as spam. 
      Undo

      You can see all pending comments posted by this user  here

      Anonymous - 2016-05-17

      Hi Tihomir,

      look here
      https://github.com/ibv/LDAP-Admin
      and here
      http://ivb.sweb.cz/ldap-en.html

      Cheers,
      Ivo

       
  • Tihomir Karlovic

    Awesome Ivo! I'm on a vacation trip right now but will be back next week, can't wait to try it out :-)

     


Anonymous

Cancel  Add attachments





Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks