locked
Creating custom authentication package RRS feed

  • Question

  • Hi

    I want to authenticate in the credential provider (Win7 logon) using user name and a key (not the password). The authentication shall be done on the active directory. Therefore I have to write a custom authentication package. 

    Does anyone have a sample code? I have followed the LSA api to implement the custom authentication package but of no use.

    Thanks

    bpt


    Monday, October 8, 2012 2:04 PM

All replies

  • Hi

    I want to authenticate in the credential provider (Win7 logon) using user name and a key (not the password). The authentication shall be done on the active directory. Therefore I have to write a custom authentication package. 

    I have followed the Lsa logon function, and as per the recommendations I am filling the function SpLsaModeInitialize with the structure SECPKG_FUNCTION_TABLE. But I am not able to load the authentication package.

    Here is the code snippet,

    NTSTATUS NTAPI SpLsaModeInitialize(
      _In_   ULONG LsaVersion,
      _Out_  PULONG PackageVersion,
      _Out_  PSECPKG_FUNCTION_TABLE *ppTables,
      _Out_  PULONG pcTables
    )
    {

    PSECPKG_FUNCTION_TABLE FunctionTable = *ppTables;

    FunctionTable->AcceptCredentials = NULL;
    FunctionTable->AcceptLsaModeContext = NULL ;

    FunctionTable->AcquireCredentialsHandleA = NULL ;
    FunctionTable->AddCredentialsA = NULL ;

    FunctionTable->ApplyControlToken = NULL ;
    FunctionTable->CallPackage = (PLSA_AP_CALL_PACKAGE)LsaApCallPackage;
    FunctionTable->CallPackagePassthrough = (PLSA_AP_CALL_PACKAGE_PASSTHROUGH) LsaApCallPackagePassthrough;
    FunctionTable->CallPackageUntrusted = (PLSA_AP_CALL_PACKAGE_UNTRUSTED) LsaApCallPackageUntrusted;

    FunctionTable->ChangeAccountPasswordA = NULL ;

    FunctionTable->DeleteContext = NULL ;
    FunctionTable->DeleteCredentials = NULL ;
    FunctionTable->ExchangeMetaData = NULL ;
    FunctionTable->FreeCredentialsHandle = NULL ;
    FunctionTable->GetCredentials = NULL ;
    FunctionTable->GetCredUIContext = NULL ;
    FunctionTable->GetExtendedInformation = NULL ;
    FunctionTable->GetInfo = NULL ;
    FunctionTable->GetUserInfo = NULL ;
    FunctionTable->Initialize = (SpInitializeFn*)SpInitialize;
    FunctionTable->InitializePackage = (PLSA_AP_INITIALIZE_PACKAGE)LsaApInitializePackage;
    FunctionTable->InitLsaModeContext = NULL ;
    FunctionTable->LogonTerminated = NULL ;
    FunctionTable->LogonUserEx2 = (PLSA_AP_LOGON_USER_EX2)LsaApLogonUserEx2;

    FunctionTable->LogonUserExA = (PLSA_AP_LOGON_USER_EX)LsaApLogonUserEx;
    FunctionTable->LogonUserA = (PLSA_AP_LOGON_USER)LsaApLogonUser;
    FunctionTable->QueryContextAttributesA = NULL ;
    FunctionTable->QueryCredentialsAttributesA = NULL ;

    FunctionTable->QueryMetaData = NULL ;
    FunctionTable->SaveCredentials = NULL ;

    FunctionTable->SetContextAttributesA = NULL ;
    FunctionTable->SetCredentialsAttributesA = NULL ;

    FunctionTable->SetExtendedInformation = NULL ;
    FunctionTable->Shutdown = (SpShutdownFn *)SpShutDown;
    FunctionTable->UpdateCredentials = NULL ;
    FunctionTable->ValidateTargetInfo = NULL ;



    return 0;

    }



    All the function pointers has been kept as a dummy functions, as follows,

    NTSTATUS LsaApCallPackage(
      _In_   PLSA_CLIENT_REQUEST ClientRequest,
      _In_   PVOID ProtocolSubmitBuffer,
      _In_   PVOID ClientBufferBase,
      _In_   ULONG SubmitBufferLength,
      _Out_  PVOID *ProtocolReturnBuffer,
      _Out_  PULONG ReturnBufferLength,
      _Out_  PNTSTATUS ProtocolStatus
    )
    {
    return 0;

    }




    Can anybody suggest where I am doing wrong?



    Thanks

    bpt

    bpt

    Tuesday, October 9, 2012 6:57 AM
  • Hello,

    First of all, you have to allocate memory for your FunctionTable and you shoud have global pointer for instance of this structure. (Just for reference in debugger, e.g.)

    Next you should write the pointer to allocated memory to the _out argument of SpLsaModeInitialize()

    *ppTables = yourFunctionTable;

    Third and last thing is you sholud write the quantity of function tables, what you are returing:

    *pcTables = 1;

    Best Regards,

    Stanislaw

    Sunday, May 19, 2013 12:35 PM