/** This function replaces the old identity policy with a new identity policy. This function delete the user identity policy information. If enroll new credential failed, recover the old identity policy. @retval EFI_SUCCESS Modify user identity policy successfully. @retval Others Fail to modify user identity policy. **/ EFI_STATUS UpdateCredentialProvider ( ) { EFI_STATUS Status; EFI_USER_INFO_IDENTITY_POLICY *Identity; UINTN Offset; // // Delete the old identification policy. // DeleteCredentialFromProviders (mUserInfo.IdentityPolicy, mUserInfo.IdentityPolicyLen, mModifyUser); // // Add the new identification policy. // Offset = 0; while (Offset < mUserInfo.NewIdentityPolicyLen) { Identity = (EFI_USER_INFO_IDENTITY_POLICY *) (mUserInfo.NewIdentityPolicy + Offset); if (Identity->Type == EFI_USER_INFO_IDENTITY_CREDENTIAL_PROVIDER) { // // Enroll the user on this provider // Status = EnrollUserOnProvider (Identity, mModifyUser); if (EFI_ERROR (Status)) { // // Failed to enroll the user by new identification policy. // So removed the credential provider from the identification policy // DeleteProviderFromPolicy (Identity, Offset); continue; } } Offset += Identity->Length; } return EFI_SUCCESS; }
/** Delete the user specified by UserIndex in user profile database. @param[in] UserIndex The index of user in the user name list to be deleted. **/ VOID DeleteUser ( IN UINT8 UserIndex ) { EFI_STATUS Status; EFI_USER_PROFILE_HANDLE User; EFI_INPUT_KEY Key; EFI_USER_INFO_HANDLE UserInfo; EFI_USER_INFO *Info; UINTN InfoSize; // // Find specified user profile and delete it. // User = NULL; Status = mUserManager->GetNext (mUserManager, &User); if (EFI_ERROR (Status)) { goto Done; } while (UserIndex > 1) { Status = mUserManager->GetNext (mUserManager, &User); if (EFI_ERROR (Status)) { goto Done; } UserIndex--; } if (UserIndex == 1) { // // Get the identification policy. // Status = FindInfoByType (User, EFI_USER_INFO_IDENTITY_POLICY_RECORD, &UserInfo); if (EFI_ERROR (Status)) { goto Done; } InfoSize = 0; Info = NULL; Status = mUserManager->GetInfo (mUserManager, User, UserInfo, Info, &InfoSize); if (Status == EFI_BUFFER_TOO_SMALL) { Info = AllocateZeroPool (InfoSize); if (Info == NULL) { goto Done; } Status = mUserManager->GetInfo (mUserManager, User, UserInfo, Info, &InfoSize); } // // Delete the user on the credential providers by its identification policy. // ASSERT (Info != NULL); DeleteCredentialFromProviders ((UINT8 *)(Info + 1), Info->InfoSize - sizeof (EFI_USER_INFO), User); FreePool (Info); Status = mUserManager->Delete (mUserManager, User); if (EFI_ERROR (Status)) { goto Done; } CreatePopUp ( EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Delete User Succeed!", L"", L"Please Press Any Key to Continue ...", NULL ); return ; } Done: CreatePopUp ( EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Delete User Failed!", L"", L"Please Press Any Key to Continue ...", NULL ); }