Skip To Content

Credential.SetAsync (.NET)

The Credential.SetAsync method sets credentials to a service for the current AutoCAD session. You must specify a service layer in the method, but secured layers added from the same server in the same AutoCAD session will use those credentials, if needed. This only works on token authentication for ArcGIS Server and ArcGIS Enterprise; it does not work on other authentication models such as OAuth. The username and password are passed in plain text to the server.

Declaration

public async Task<bool> Esri.ArcGISForAutoCAD.Credential.SetAsync(string url, string username, string password)

Parameters

TypeNameDescriptionRequired

string

url

The URL path to a valid web feature layer.

required

string

username

The existing username with permission to access the layer.

required

string

password

The password for the specified username.

required

Returns

TypeDescription

bool

true if the credentials were set successfully

Remarks on error conditions

This method may throw an exception or return false or null if a parameter is invalid.

Example

Print the success of setting the token authentication username and password credentials for the included web feature layer in the current AutoCAD session.

// Initialize
var doc = Application.DocumentManager.MdiActiveDocument;
var url = "https://myserver.domain.com/arcgis/rest/services/mySecuredLayer/FeatureServer/0";

// Set credentials
var success = await Esri.ArcGISForAutoCAD.Credential.SetAsync(url, "MyGISUser", "MyPassword");

// Print the success
doc.Editor.WriteMessage(success.ToString());

/* Example output 
True
*/

See also

esri_credential_set—An AutoLISP function that sets credentials to a service for the current AutoCAD session.