Authentication Triggers: Compiling the Examples
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.plYou 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::SASLYou 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 -lldapReturns:
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 scopeFixed by adding "-DLDAP_DEPRECATED" to the "g++" options.
The command:
gcc p4auth_ad-debug4.cpp -DLDAP_DEPRECATED -lldapReturns:
/tmp/cctXiSGp.o:(.eh_frame+0x11): undefined reference to `__gxx_personality_v0' collect2: ld returned 1 exit statusFixed 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.batThen compile:
C:\build>cl /EHs p4authenticate.cpp /link Wldap32.LibSome 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
