Seyed Amin
Seyed Amin

Reputation: 81

Adding a new text field pGina

I need to have a third text field besides the Username and Password fields commonly provided by pGina in windows logon UI. I'll be using this field to receive a password to be checked against a one-time password service running in the background.

How can I add the new field in the pGina logon UI and pass its value to a services running in the background?

Any help is appreciated.

Upvotes: 2

Views: 1127

Answers (3)

Seyed Amin
Seyed Amin

Reputation: 81

I finally managed to to this.

As pointed out by @Alexander, I edited the TileUiLogon.h and TileUiTypes.h and followed the pattern to add a third field to the logon screen. Then, I edited Credential::Initialize and added a new line in the "for" loop, following the same pattern for the "password" field (I'm not sure exactly what happens there, but since we're complying with the existing pattern, we don't care as long as the content of the new field is collected by the code similar to the other fields).

Since I didn't want to go through changing all the function signatures and mess with the code, I simply edited the Credential::ProcessLoginAttempt function and concatenated the content of the new field with that of the password field and embedded a custom delimiter to allow me separate the two strings in the following steps. After hitting the submit button, the fields data, prior to the real serialization, are initially sent to a pipe on the other end of which the pGina service is listening (pGinaTransactions.cpp). This service sends the login information to its plugins. I then edited the "Sample" plugin already provided and separated the two concatenated strings, immediately filling the password attribute of the object with the real password provided by the user, since these data will be sent back to the credential provider through pipe for further processing. If the plugin returns success, the password is then used for real serialization and logon attempt.

I have probably missed a few details, which you are very welcome to ask in the comments.

Upvotes: 3

Alexander
Alexander

Reputation: 1341

I think you must modify TileUiLogon.h file:

namespace pGina { namespace CredProv { // Fields for unlock and logon: typedef enum LOGON_UI_FIELD_ID { LUIFI_TILEIMAGE = 0, LUIFI_MOTD = 1, LUIFI_USERNAME = 2, LUIFI_PASSWORD = 3, LUIFI_OTP = 4, LUIFI_SUBMIT = 5, LUIFI_STATUS = 6, LUIFI_NUM_FIELDS = 7, };

    static const UI_FIELDS s_logonFields =
    {
        LUIFI_NUM_FIELDS,       // Number of fields total
        LUIFI_PASSWORD,         // Field index which submit button should be adjacent to
        LUIFI_USERNAME,         // Username field index value
        LUIFI_PASSWORD,         // Password field index value
        LUIFI_STATUS,           // Status field
        {
            //  when to display,               style,             field id,        type,               name           data source     value         callback
            { { CPFS_DISPLAY_IN_BOTH,          CPFIS_NONE },    { LUIFI_TILEIMAGE, CPFT_TILE_IMAGE,    L"Image" },    SOURCE_NONE,    NULL,         NULL }, 
            { { CPFS_DISPLAY_IN_BOTH,          CPFIS_NONE },    { LUIFI_MOTD,      CPFT_SMALL_TEXT,    L"MOTD" },     SOURCE_DYNAMIC, L"pGina",     NULL }, 
            { { CPFS_DISPLAY_IN_SELECTED_TILE, CPFIS_FOCUSED }, { LUIFI_USERNAME,  CPFT_EDIT_TEXT,     L"Username" }, SOURCE_NONE,    NULL,         NULL }, 
            { { CPFS_DISPLAY_IN_SELECTED_TILE, CPFIS_NONE },    { LUIFI_PASSWORD,  CPFT_PASSWORD_TEXT, L"Password" }, SOURCE_NONE,    NULL,         NULL }, 
            { { CPFS_DISPLAY_IN_SELECTED_TILE, CPFIS_NONE },    { LUIFI_OTP,  CPFT_PASSWORD_TEXT, L"OTP" },         SOURCE_NONE,    NULL,           NULL },
            { { CPFS_DISPLAY_IN_SELECTED_TILE, CPFIS_NONE },    { LUIFI_SUBMIT,    CPFT_SUBMIT_BUTTON, L"Submit" },   SOURCE_NONE,    NULL,         NULL }, 
            { { CPFS_DISPLAY_IN_BOTH,          CPFIS_NONE },    { LUIFI_STATUS,    CPFT_SMALL_TEXT,    L"Status" },   SOURCE_STATUS,  L"Status",    NULL },
        }
    };
}

}

and other related files like pGinaTransactions.h and so on to handle new field. ;-)

Upvotes: 1

Kianii
Kianii

Reputation: 161

As far as i know (if you're on Vista or above), you gonna have to make your own Credential Provider and register it.

For the interaction with the service, i'd say it depends wether it's running in local or on a distant server. Anyway, that's probably the easy part of the work.

UPDATE : I don't know pGina like AT ALL. But you should look at gina.rc (line 93) under DIALOGS. Seems to be an interesting place to begin.

Try to add a custom EDITEXT (by the way, lots of IDE most likely have a visualizor for those resources. I know that Visual Studio is one of them as i already experienced it.)

Visualizor and resource.h --> /!\ This is a screenshot of what it looks like and the resource.h.

//Third TEXTEDIT I just added
EDITTEXT        IDC_CUSTOM_PASSWORD_TXT, 146, 88, 183, 12, ES_PASSWORD | ES_AUTOHSCROLL

Upvotes: 0

Related Questions