Share via


LocationServiceSoap.AddContact Method

Adds a contact to the list of contacts for the current user.

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

      _ As LocationServiceSoap.LocatableContact
[C#]
public LocationServiceSoap.LocatableContact AddContact (System.String domainAlias,      System.Boolean isActive,      System.Boolean notifyOnLocate);

Parameters

  • domainAlias
    The domain and alias of the contact user to be added to the current user, in the format "domain\user". The domainAlias parameter is required must be passed as a string. For information about the maximum length of the domainAlias argument, see MapPoint Location Server Parameter Lengths.
  • isActive
    A flag that indicates whether this contact relationship is active. If the contact relationship is active, the flag 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 set to True. For more information, see ContactStatus Enumeration.
  • notifyOnLocate
    A flag that indicates if the user should be notified when the contact tries to locate him or her. This flag 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 an instance of LocatableContact class upon successfully adding a new contact.

This method accepts the following SOAP headers:

UserInfoLocationHeader—Used to establish the current user's (the user that is invoking the location service) specific information, such as culture and so on. When this SOAP header is not provided, the current user's default culture is applied. For more information, see UserInfoLocationHeader Class.

ClientIdHeader—Not used with MapPoint Location Server 1.0.

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

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

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

Because this is a Web service, all exceptions appear as SOAP exceptions. For more information, see the SoapException.Detail property.

Example

 
[Visual Basic]
    'Create a LocationServiceSoap proxy instance.
    Dim MyLocationService As New LocationServiceSoap
    'Create and add the credentials required to access the Web service.
    Dim MyCredentials As New NetworkCredential("user", "password", "DOMAIN")
    MyLocationService.Credentials = MyCredentials

    Try
        'Add a new contact for the current user
        Dim MyLocatableContact As LocatableContact = MyLocationService.AddContact("DOMAIN\contactuser", True, True)

    Catch MyException As SoapException
        'Your exception processing goes here.
        If ((Not MyException.Detail Is Nothing) And (Not MyException.Detail("Type") Is Nothing)) Then
            MessageBox.Show(MyException.Detail("Type").InnerText)
        End If

    Finally
        'Your cleanup goes here
        MyLocationService = Nothing
    End Try

 
[C#]
  //Create a LocationServiceSoap proxy instance.
  LocationServiceSoap MyLocationService = new LocationServiceSoap();
  //Create and add the credentials required to access the Web service.
  NetworkCredential MyCredentials = new NetworkCredential("user", "password", "DOMAIN");
  MyLocationService.Credentials = MyCredentials;

  try
  {
   //Add contact to the current user
   LocatableContact MyLocatableContact = MyLocationService.AddContact(@"DOMAIN\contactuser", true, true);
  }
  catch(SoapException MyException)
  {
   //Your exception processing goes here.
   if (MyException.Detail != null && MyException.Detail["Type"] != null)
    MessageBox.Show(MyException.Detail["Type"].InnerText);
  }
  finally
  {
   //Your cleanup goes here
   MyLocationService = null;
  }
 
  
 

See Also

Location Service Class  |  LocatableContact Class  |  UserInfoLocationHeader Class  |  ContactStatus Enumeration  |  Active Contact Definition  |  Notify On Locate Definition  |  Contact Definition  |  Using Soap Headers