ServerAPI.AddUser Method
Adds a new user to MapPoint Location Server. Adding a user is also called provisioning a user.
Public Sub AddUser (userInfo As Microsoft.MapPoint.LocationServer.Types.LocatableUser)
[C#]
public AddUser (Microsoft.MapPoint.LocationServer.Types.LocatableUser userInfo);
Parameters
userInfo
User information as an instance of a LocatableUser class. When user information is passed in the form of a LocatableUser object, not all properties are required. The following properties are ignored even if they are set:
FirstName LastName DisplayName EmailAddress
These values are retrieved from Microsoft® Active Directory® when a valid domain alias is provided.The following properties of the LocatableUser object are required:
DomainAlias—The domain and alias of the user that is being added to MapPoint Location Server (in other words, the user that is being provisioned); for example, "domain\user". When an invalid value is supplied for this property, an InvalidDomainAlias exception is thrown. When no match is found for the domain and alias in Active Directory, a NoExactMatchOnDomainAliasException exception is thrown. CultureName—The culture name in the format "languagecode2-regioncode2", where languagecode2 is a lowercase two-letter code derived from International Organization for Standardization (ISO) 639-1 and regioncode2 is an uppercase two-letter code derived from ISO 3166. For example, "en-US" denotes English (United States). If an invalid culture name is supplied for this property, an InvalidCultureNameException exception is thrown.The following values of the LocatableUser object are optional:
LocationProviderName—In general, it is the name of a location service provider as it appears in the MapPoint Location Server management console. With MapPoint Location Server version 1.0, there is no way to retrieve location provider names from MapPoint Location Server programatically. See your administrator for valid provider names. When an invalid name is supplied for this property, a ProviderNotFoundException exception is thrown. LocatableEndpoint—Although optional, this property must be set with a valid value when the LocationProviderName property is set. This property is usually a mobile phone number or a pager number. When an invalid value is supplied for this property, the NotAValidNumberException exception is thrown. NotificationProviderName—In general, this property contains the name of a notification service provider (which is sometimes same as the location service provider) as it appears in the MapPoint Location Server management console. With MapPoint Location Server version 1.0, there is no way to retrieve location provider names from MapPoint Location Server programmatically. See your administrator for valid provider names. When an invalid name is supplied for this property, a ProviderNotFoundException exception is thrown. NotificationEndpoint—Although optional, this property, however, must be set with a valid value if the NotificationProviderName property is set. This property is usually a mobile phone number, a pager number, or an e-mail address.The following properties are also optional. When these properties are not set, they default to true.
NotifyOnNewContact Visible
Remarks
This method takes user information in the form of a LocatableUser object.
Certain properties are retrieved from Microsoft® Active Directory® when a new users is added to MapPoint Location Server.
If the Active Directory server is not operational, an ActiveDirectoryServerNotOperationalException exception is thrown.
If the domain and alias for a specified user cannot be found in Active Directory, an ActiveDirectorySearchErrorException exception is thrown.
Example
[Visual Basic]
'Create a new instance of the ServerAPI class
Dim MyServerAPI As New ServerAPI
Try
'Create a LocatableUser instace
Dim NewUser As New LocatableUser
'Set the domain alias
NewUser.DomainAlias = "DOMAIN\user"
'Set the culture name
NewUser.CultureName = "en-US"
'Set the Locatable end point - This is the user's mobile device number
NewUser.LocatableEndpoint = New LocatablePhoneNumber("001", "111", "1111111")
'Set the Location Provider name - Should get it from your Administrator
NewUser.LocationProviderName = "Your Location Provider Name"
'Set the Notification Provider name - Should get it from your Administrator
NewUser.NotificationProviderName = "Your Notification Provider Name"
'Set the Notification end point Could be a email address or a mobile devide number
NewUser.NotificationEndpoint = "user email address"
'Initialize the database connection for ServerAPI operations
MyServerAPI.Initialize("Your SQL Server Name", "LocationServerDB")
'Now add a domain user to the MapPoint Location Server
MyServerAPI.AddUser(NewUser)
Catch MyException As Exception
'Process your exceptions here
Console.WriteLine(MyException.GetType().Name)
Finally
'Do cleanup
MyServerAPI = Nothing
End Try
[C#]
//Create a new instance of the ServerAPI class
ServerAPI MyServerAPI = new ServerAPI();
try
{
//Create a LocatableUser instace
LocatableUser NewUser = new LocatableUser();
//Set the domain alias
NewUser.DomainAlias = @"DOMAIN\user";
//Set the culture name
NewUser.CultureName = "en-US";
//Set the Locatable end point - This is the user's mobile device number
NewUser.LocatableEndpoint = new LocatablePhoneNumber("001", "111", "1111111");
//Set the Location Provider name - Should get it from your Administrator
NewUser.LocationProviderName = "Your Location Provider Name";
//Set the Notification Provider name - Should get it from your Administrator
NewUser.NotificationProviderName = "Your Notification Provider Name";
//Set the Notification end point; Could be a email address or a mobile devide number
NewUser.NotificationEndpoint = "user email address";
//Initialize the database connection for ServerAPI operations
MyServerAPI.Initialize("Your SQL Server Name", "LocationServerDB");
//Now add a domain user to the MapPoint Location Server
MyServerAPI.AddUser(NewUser);
}
catch(Exception MyException)
{
//Process your exceptions here
Console.WriteLine(MyException.GetType().Name);
}
finally
{
//Do cleanup
MyServerAPI = null;
}
See Also
LocatableUser Class | Microsoft.MapPoint.LocationServer.Management | ServerAPI Class | ServerAPI Members | ServerAPIException Class