I know the question is pretty old but I think it is still a question that many administrators have.
The answers given do not get even close to what was asked.
In both answers you already have to know the user object to get more info about it.
But the question is how to get the user object when you only know a part of the Lastname and the SamAccountName has nothing in common with the DisplayName or the LastName of the user.
Example: Lastname: Miller, SamAccountName: XY123456
You know the LastName or a part of it and want to query for the SamAccountName. How do you do that with the AD UDF?