Import user name and password automatically with AppleScript or Unix Shell
I have installed Egnyte Drive to test your script.

I have found out that you don't need to activate the application at all. Instead "SecurityAgent" is the only process that needs to be addressed:

tell application "System Events" to tell process "SecurityAgent"
    set value of text field 1 of window 1 to "user"
    if exists (text field 2 of window 1) then
        set value of text field 2 of window 1 to "password"
    end if
    click button "OK" of window 1
end tell


Let me know if this works for you as well. I tested it with macOS Sierra 10.12.2 beta.