Hi Susmita,
If you got the user by providing full UniqueID than it will be the LDAP/UME user UME should return the correct user.
UniqueID is unique across portal, meaning that there shouldn't be the same UniqueID on LDAP and UME.
if you use the UserFactory.getUser(uniqueID) method it should return the correct user each time and you should be able to do the locking.
BR,
Saar