Getting contact list from IMAP server
IMAP only deals with folders of RFC822 messages. There's no standard for contact storage on the server. That said, I believe Exchange makes contacts available via its IMAP server in a non-standard fashion. I am not aware of a library that makes it easy to use this information.
Most desktop IMAP clients allow you to use an LDAP directory to augment your contact list. If the IMAP server also uses this LDAP directory for authentication, your client can search the list of valid addresses.
IMAP -- by itself -- does not provide any functionality for synchronizing contacts. IMAP is essentially a remote file access protocol with some mail-specific metadata trappings. You can use it to (a) get message, (b) store messages, and (c) search for messages, and that's it.
You can use an IMAP server to synchronize contacts between multiple mail clients by simply storing your address book as a "message" on the IMAP server. Alpine does this, and uses the same technique for synchronizing configurations across multiple systems.