If a person is willed a house and comes in and throws all the stuff he didn’t want in a dumpster, is it okay to take a peek and grab anything to your liking? Then supposing one did this and found out at a later date one of the items might have a little value to it. What is okay? Is it rightfully yours? Considering that it’s okay to peek and take in the first place?
If someone puts something in a dumpster, he has abandoned ownership. Assuming that the laws of your municipality allow for dumpster diving, it is not wrong to take from a dumpster anything you like. If what you take turns out to have value, it is rightfully yours and you need not return the object or share profits from its sale with the original owner. (As a courtesy though, you also should not brag to him of your good fortune in finding the treasure he threw away.) If the object has considerable value, it is still yours to do with whatever you wish, but it would be a great kindness to share any profits made from its sale with the original owner – especially if he is particularly needy or if the object was part of an inheritance.