Google Connector - existing Google user accounts

Hi all,

The topic is already older. I wrote a script to link users which already exist in Google with the UCS.

#!/bin/bash

admin="username"
mail="$1"

LDAPMODIFY="ldapmodify -H ldaps://localhost:7636 -x -D uid=$admin,cn=domain,cn=tld -W"

if [ -z "$mail" ]; then
        echo "mail not set!"
        exit 1
else
        echo "search DN for: $mail"
fi

dn=$(univention-ldapsearch mail="$mail" | grep dn: | awk '{print $2}')
if [ -z "$dn" ]; then
        echo "could not set DN, exit"
        exit 1
else
        echo "DN found: $dn"
fi

id=$(/usr/share/univention-google-apps/print_google_users_and_groups \
        | grep "$mail" | head -n1 | awk '{print $1}')

if [ -z "$id" ]; then
        echo "could not set ID, exit"
        exit 1
else
        echo "ID found: $id"
fi

cat << EOF | $LDAPMODIFY
dn: $dn
changetype: modify
add: univentionGoogleAppsObjectID
univentionGoogleAppsObjectID: $id
EOF

cat << EOF | $LDAPMODIFY
dn: $dn
changetype: modify
add: univentionGoogleAppsPrimaryEmail
univentionGoogleAppsPrimaryEmail: $mail
EOF

cat << EOF | $LDAPMODIFY
dn: $dn
changetype: modify
add: univentionGoogleAppsEnabled
univentionGoogleAppsEnabled: 1
EOF

1 Like