ServerAPI.AddContact Method

Adds a new contact for a given user.

Public Function AddContact (domainAlias As System.String, _      contactDomainAlias As System.String, _      isActive As System.Boolean, _      notifyOnLocate As System.Boolean)

      _ As Microsoft.MapPoint.LocationServer.Types.LocatableContact
[C#]
public Microsoft.MapPoint.LocationServer.Types.LocatableContact AddContact (System.String domainAlias,      System.String contactDomainAlias,      System.Boolean isActive,      System.Boolean notifyOnLocate);

Parameters

  • domainAlias
    The domain and alias of the user to which a new contact is being added. The domainAlias parameter is required and must be in the format "domain\user". For information about the maximum length of the domainAlias argument, see MapPoint Location Server Parameter Lengths.
  • contactDomainAlias
    The domain and alias of the contact that is being added to the contact list. The contactDomainAlias parameter is required and must be in the format "domain\user". For information about the maximum length of the contactDomainAlias argument, see MapPoint Location Server Parameter Lengths.
  • isActive
    A flag that indicates whether a given contact relationship is active. If the contact relationship is active, the value is set to True. If the contact relationship is not active (blocked), the value is set to False. The default value for this parameter is True. For more information, see ContactStatus Enumeration.
  • notifyOnLocate
    A flag that indicates whether the user is notified when the contact tries to locate him or her. This value is set to True if the user wants to receive a notification and False if the user does not. The default value for this parameter is True.

Remarks

This method returns a LocatableContact instance when a new contact is added successfully.

If the contact already exists in the contacts list, a ContactRelationshipAlreadyExistsException exception is thrown.

If the domainAlias parameter is the same as the contactDomainAlias parameter, a SelfReferentialContactException exception is thrown.

If the user specified by the domain alias string cannot be found in the MapPoint Location Server database, a UserNotProvisionedException exception is thrown.

Example

 
[Visual Basic]
    'Microsoft SQL Server and database instance names. 
    Const server As String = "Your SQL Server Name"
    Const database As String = "LocationServerDB"
    'Create a ServerAPI instance. 
    Dim MyServerAPI As New ServerAPI
    Try
        'Call initialize. 
        Call MyServerAPI.Initialize(server, database)
    Catch MyException As SqlConnectionFailedException
        'Your exception processing goes here
    End Try
    'If Initialize method call is successful. 
    Dim MyDomainAlias As String = "DOMAIN\user"
    Dim NewContact As String = "DOMAIN\newcontact"
    Try
        Dim MyLocatableContact As LocatableContact = MyServerAPI.AddContact(MyDomainAlias, NewContact, True, True)
        Console.WriteLine(MyLocatableContact.DisplayName)
    Catch MyException As Exception
        'Your exception handling goes here. 
    End Try

 
[C#]
  //Set the computer running SQL Server and database instance names. 
  const string server = "your sql server name"; 
  const string database = "LocationServerDB"; 
  //Create a ServerAPI instance. 
  ServerAPI MyServerAPI = new ServerAPI(); 
  try 
  { 
   //Call initialize.
   MyServerAPI.Initialize(server, database); 
  } 
  catch(SqlConnectionFailedException MyException) 
  {
   //Your exception processing goes here. 
  }
   
  //If Initialize method call is successful. 
  string MyDomainAlias = @"DOMAIN\user"; 
  string NewContact = @"DOMAIN\newcontact"; 
  try 
  { 
   LocatableContact MyLocatableContact = MyServerAPI.AddContact(MyDomainAlias, NewContact, true, true);
   Console.WriteLine(MyLocatableContact.DisplayName); 
  }
  catch(Exception MyException) 
  {
   //Exception handling goes here. 
  }
  
 

See Also

ContactStatus Enumeration  |  LocatableContact  |  Microsoft.MapPoint.LocationServer.Management  |  ServerAPI Class  |  ServerAPI Members  |  ServerAPIException Class