When a local Communicator instance is up and running, signing in means connecting the application to the Communicator instance. This is accomplished when the application creates a Messenger object.

If the local Office Communicator 2007 is signed out, the application can call the IMessenger::AutoSignin method to connect Communicator to a Microsoft® Office Communications Server using the preconfigured settings and user credentials. The call logs a user into the Communications Server in the same way as the user does by clicking Sign In on the Connect menu.

In addition, the application can call the IMessenger::Signin method to sign in with explicit user credentials as specified in the parameters of the method. A call to this method launches a Sign-In Account dialog box, as shown in the following figure.

In response to a call of the IMessenger::Signin method or the IMessenger::AutoSignin method, Office Communicator Automation API raises an event to inform the application of the status of sign-in request, if the application has registered to receive the DMessengerEvents::OnSignin event and implemented the corresponding event handler.

Signing In from a C# Application

The following C# code snippet illustrates how to sign in to the communications service using Office Communicator Automation API.

Copy Code
// Global or class variable
CommunicatorAPI.Messenger communicator;
bool connected = false;

// A simple implementation of signing in.
void Signin(string account, string passwd)
   if (connected)

   if (communicator == null)
	// Create a Messenger object, if necessary
	communicator = new CommunicatorAPI.Messenger();

	// Register event handlers for OnSignin and Signout events
	communicator.OnSignin += new DMessengerEvents_OnSigninEventHandler(communicator_OnSignin);
	communicator.OnSignour += new DMessengerEvents_OnSignoutEventHandler(communicator_OnSignout);

	// Register more event handlers as appropriate. (Omitted)
   if (account == null)
	communicator.Signin(account, passwd);

// Event handler for OnSignin event.
void communicator_OnSignin(int hr)
   if (hr != 0)
	Console.WriteLine("Signin failed.");

   connected = true;

   // Display contacts to a console window(for illustration only).
   foreach (IMessengerContact contact in communicator.MyContacts as IMessengerContacts)
	if (!contact.IsSelf)
		 Console.WriteLine("{0} ({1})", contact.SigninName, contact.Status);

For an example of the event handler for an OnSignout event, see Signing Out from a Communications Server.

See Also