Can a rogue or assassin, with 6 or 7 total levels, use sneak attack when he is attacking someone with Improved Uncanny Dodge, like a barbarian 5th or Warblade 6th?
- If rogue attack from invisibilty
- If rogue flanks target
Invisibility: A barbarian of 2nd level and above will keep it's dexterity bonus to AC if attacked by an invisible attacker. That's explicitly stated in his 2nd level feat Uncanny Dodge. There is no way to mitigate this defense through being higher level.
Flanking: A rogue needs to be 4 rogue class levels above the 5th level barbarian with his Improved Uncanny Dodge to be able to flank him effectively.
So a rogue only one or two class levels as rogue above a 5th level barbarian cannot use sneak attack against the barbarian through Invisibility or Flanking alone. The only effective way to use sneak attack would be a means to have the barbarian immobilized prior to the attack, because that would negate his benefits from Uncanny Dodge (cannot dodge if you cannot move). Other options to remove the barbarians bonus to dexterity would include feinting and various grappling situations.
As the Warblade gets Uncanny Dodge at level 2 and Improved Uncanny Dodge at level 6, the same goes for a Warblade of level 6.