How does IDENT work?
(Note: This answer is tailored to the U.S. / FAA, because that is what I'm familiar with. All the citations and references are FAA materials. If anyone has any tips on possible international differences, please let me know and I'll edit them in. That said, I believe the descriptions I give are fairly consistent across the world, even if the FAA reg citations don't directly apply.)


  In what situations does ATC ask for ident, and is it ever required by procedure?


Generally, "ident" is used to help a controller identify an aircraft's secondary radar (transponder) return. By asking the pilot to "squawk ident," the controller can ensure that the aircraft he/she is talking to matches the radar target he thinks is that aircraft.

It can also be used for communication, to allow a pilot to respond if their radio transmitter has failed.

Specifically:


It is a method to allow a controller to identify an aircraft on radar, per section 5-3-3 of FAA Order 7110.65 (pdf):



  When using only Mode 3/A radar beacon to identify a target, use one of the following methods:
  
  a. Request the aircraft to activate the "IDENT" feature of the transponder and then observe the identification display.



For lost communication, per section 10-4-4 of 7110.65:



  Take the following actions, as appropriate, if two-way radio communications are lost with an aircraft:
  
  c. Attempt to re-establish communication by having the aircraft use its transponder or make turns to acknowledge clearances and answer questions. Request any of the following in using the transponder:
  
  1. Request the aircraft to reply Mode 3/A “IDENT.”


This last scenario is common when experiencing radio failures. If ATC suspects that you might be able to hear them but not to talk back, they might say something like "Cessna 12345, if you can hear me, squawk ident." If you reply by pressing the IDENT button, they can then issue you further instructions and ask you to acknowledge those instructions by pressing IDENT again.




  What does the transponder actually do in this mode?


In normal operation, every time the transponder receives an interrogation from a ground station, it replies with a data block containing certain pieces of information. This data block contains:


The encoded pressure altitude (for Mode C transponders)
A 12-bit identification code (this is the 4-digit code you select in the cockpit)
A single extra bit for the "ident" flag


When you push the IDENT button in the cockpit, the transponder sets that extra "ident" bit in its reply data. Anytime the transponder is interrogated while IDENT is active (for a set duration of time after you press the button in the cockpit), its reply data block will have the IDENT bit set. ATC computer systems notice this and cause the IDENT to be shown on the controller's radar display.




  What does the controller see on their screen?


It depends on the type of radar system in use. Generally the radar target will either blink, its symbol will change (or "blossom"), or an indication such as "ID" will blink in the aircraft's data block (where the callsign is shown).

The AIM has some schematic pictures that show what an IDENT looks like on an ARTS-III scope (an older system still in use at some TRACONs). See Figures 4-5-2 and 4-5-3.

I will try to find some pictures of other radar systems such as those used at ARTCCs and newer TRACONs.




  Does it depend at all on either the code or the mode the transponder is currently set for?


The code doesn't matter. The IDENT flag is an extra bit in the transponder's reply data that's independent of the 12 bits used for the code.

Obviously the IDENT will only be observed if the transponder is operating (not OFF or in a STANDBY mode). But the IDENT works in any mode used by normal civilian transponders (Modes A, C or S).