Helix Core is now P4. Product user interfaces will be updated soon. Learn more >>

P4 Server Administration Documentation | 2025.1

# Sample trigger

The following code sample is a bash `auth-check` type trigger that tries to authenticate a user (passed to the script using the `%user%` variable) using the Active Directory. If that fails, all users have the same "secret" password, and special user `bruno` is able to authenticate without a password.

Copy

    USERNAME=$1
    echo "USERNAME is $USERNAME"

    # read user-supplied password from stdin
    read USERPASS
    echo Trying AD authentication for $USERNAME
    echo $USERPASS | /home/perforce/p4auth_ad 192.168.100.80 389 DC=ad,DC=foo,DC=com $USERNAME
    if [ $? == 0 ]
    then
         # Successful AD
         echo Active Directory login successful
         exit 0
    fi
    # Compare user-supplied password with correct password, "secret"
    PASSWORD=secret
    if [ "$USERPASS" = $PASSWORD ]
    then
         # Success
        exit 0
    fi
    if [ "$USERNAME" = "bruno" ]
    then
        # Always let user bruno in
        exit 0
    fi
    # Failure
    # password $USERPASS for $USERNAME is incorrect;
    exit 1

To define this trigger, use the `p4 triggers` command, and add a line like the following to the triggers form:

    bypassad auth-check auth "/home/perforce/bypassad.sh %user%"

The `auth-check` trigger is fired, if it exists, after a user executes the `p4 login` command. For authentication triggers, the password is sent on STDIN.

For operator users, use an `auth-check` trigger rather than the `service-check` trigger. See Types of users in the P4 CLI Reference.

Your search for returned results