{
var featureServiceMapView = MapView.Active;
if (featureServiceMapView == null)
return;
await QueuedTask.Run(() =>
{
Layer selectedLayer = featureServiceMapView.GetSelectedLayers()[0];
if (selectedLayer is FeatureLayer)
{
FeatureLayer featureLayer = selectedLayer as FeatureLayer;
using (Table table = featureLayer.GetTable())
using (Datastore datastore = table.GetDatastore())
{
ServiceConnectionProperties serviceConnectionProperties = datastore.GetConnector() as ServiceConnectionProperties;
if (serviceConnectionProperties == null)
{
return;
}
Uri url = serviceConnectionProperties.URL; // Will be the URL to the Feature Service.
string user = serviceConnectionProperties.User; // The username property will only be
// populated for feature service hosted
// on non-federated ArcGIS Server.
string password = serviceConnectionProperties.Password; // Will always be empty.
}
}
});
}
Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)