Yes you can do what you ask,
First you need a few things, get and install both yum and createrepo rpm packages from Dag Wieers's site;
http://dag.wieers.com/packages/
Next create your repo location (lets call it /RHEL4 for now) on the hard drive and copy all the rpm files from the CD's or DVD media to this common location. Then from that location type something like; createrepo /RHEL4
When done you can then use this with yum but first you need to create a RHEL-MEDIA.repo file in /etc/yum.repo.d directory;
[rhel-media]
name=Red Hat-$releasever - Media
baseurl=file:///RHEL4
gpgcheck=1
enabled=0
Then you should be able to install samba and all the dependencies by simply typing something like; yum -y install samba samba-swat