Authentication Triggers: Compiling the Examples

Info & Tags

Article #:
468
Created:
02/22/06
Modified:
06/24/08

Related Articles

Links

  1. ActivePerl for Windows
    External site
  2. Authen::SASL Perl Module
    External site
  3. Comprehensive Perl Archive Network (CPAN)
    External site
  4. CygWin
    External Site
  5. Net::LDAP Perl Module
    External site
  6. OpenLDAP
    External site
  7. p4authenticate.c
    Example authentication trigger
  8. p4authenticate.pl
    Example authentication trigger

TASK

What do I need to compile the LDAP trigger examples?

What are the dependencies?

DETAILS

Perl (required for p4authenticate.pl)

Confirm that you have these two modules installed before you run the p4authenticate.pl Perl script:
You can obtain both modules, if missing, from the Comprehensive Perl Archive Network (CPAN).

Module installation under Unix/Cygwin/Mac OS X

To install Perl modules, enter these commands:
perl -MCPAN -e 'install "Net::LDAP"'
perl -MCPAN -e 'install "Authen::SASL"'
To see what modules you already have installed, paste the following code into a new text document:
#!/usr/local/bin/perl

use ExtUtils::Installed;
my $instmod = ExtUtils::Installed->new();
foreach my $module ($instmod->modules()) {
my $version = $instmod->version($module) || "???";
       print "$module -- $versionn";
}
Save this as "checkmod.pl".

Run the following script from the command line:
perl checkmod.pl
You now have a list of installed modules. If you have a large number of modules installed, you can pare down the listing by piping through "grep". For example:
perl checkmod.pl | grep -E 'LDAP|SASL'

Module installation under Windows using ActivePerl for Windows

To install Perl modules, enter these commands:
ppm install Net::LDAP
ppm install Authen::SASL
You can check a list of installed modules with the command:
ppm list

C/C++ (required for p4authenticate.c)

UNIX/CygWin/MacOS X:

To properly compile the C example, you need to have a compatible LDAP library. You can obtain one from a variety of sources, including OpenLDAP, which comes installed on many systems.

To compile p4authenticate.c:
g++ -o p4authenticate p4authenticate.c -lldap

Troubleshooting

The command:
g++ p4auth_ad-debug4.cpp -lldap
Returns:
p4auth_ad-debug4.cpp: In function ‘int authCheck(char*, char*, char*, char*, char*)’:
p4auth_ad-debug4.cpp:52: error: ‘ldap_init’ was not declared in this scope
p4auth_ad-debug4.cpp:62: error: ‘ldap_bind_s’ was not declared in this scope
p4auth_ad-debug4.cpp:107: error: ‘ldap_unbind’ was not declared in this scope
Fixed by adding "-DLDAP_DEPRECATED" to the "g++" options.

The command:
gcc p4auth_ad-debug4.cpp -DLDAP_DEPRECATED -lldap
Returns:
/tmp/cctXiSGp.o:(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
Fixed by using "g++" instead of "gcc".

Windows

The ldap dll that the trigger is compiled against should exist on W2K, XP and 2K3 platforms in the form of wldap32.dll. If it is not present, you may get a pop-up error when running the trigger manually, or it will not work at all. If you have the wrong version, you might see the error "invalid ordinal 330 in winldap.dll" or similar when you try to run p4authenticate.exe.

You will need the Microsoft Platform SDK, which should come with an MS Visual Studio installation. You can download the SDK if it did not come with your Visual Studio installation. Note that the free version of the MS Visual C compiler has trouble with the header files included with the Platform SDK, so if possible, use MSVS.

To build:

First run vcvars32.bat to set the environment:
C:\build>vcvars32.bat
Then compile:
C:\build>cl /EHs p4authenticate.cpp /link Wldap32.Lib
Some debug information if your environment is broken:
C:\build>more vcvars32.bat
"%VS71COMNTOOLS%vsvars32.bat"

C:\build>env | grep -i vs71comntools
VS71COMNTOOLS=C:\Program Files\Microsoft Visual Studio .NET 2003\Common7Tools