---
title: "Get Server-Wide Connection Strings"
url: "https://docs.ravendb.net/7.2/integrations/connection-strings/server-wide/get-connection-strings"
version: "7.2"
language: "csharp"
---

# Get Server-Wide Connection Strings

> Client language: C#.
>
> RavenDB publishes an official agent skill for coding assistants at https://docs.ravendb.net/skills/ravendb/SKILL.md (also installable with `npx skills add ravendb/skills`). The skill describes itself as: "Read this before writing any RavenDB query, client call or /databases/ request. Covers server setup, document modelling, the Node.js, .NET and Python clients, RQL, indexes, vector search and AI agents. Code written from recall tends to run and return the wrong rows, because RQL resembles SQL and the clients take field names as plain strings."

> **Note**
>
> - Use `GetServerWideConnectionStringsOperation` to retrieve a specific server-wide connection string,  
>   or all server-wide connection strings defined at the cluster level.
>
> - This operation reads server-wide connection strings from the cluster-level configuration.  
>   To get connection strings stored in a single database's record, see [Get per-database connection strings](https://docs.ravendb.net/7.2/integrations/connection-strings/per-database/get-connection-strings.md).
>
> - Learn more about server-wide connection strings in [Server-wide connection strings - Overview](https://docs.ravendb.net/7.2/integrations/connection-strings/server-wide/overview.md).  
>   To create or update a server-wide connection string, see [Add or update a server-wide connection string](https://docs.ravendb.net/7.2/integrations/connection-strings/server-wide/add-or-update-connection-string.md).
>
> - In this article:
>   - [Get a server-wide connection string by name and type](#get-a-server-wide-connection-string-by-name-and-type)
>   - [Get all server-wide connection strings](#get-all-server-wide-connection-strings)
>   - [Syntax](#syntax)

## Get a server-wide connection string by name and type {#get-a-server-wide-connection-string-by-name-and-type}

The following example retrieves a server-wide `Raven` connection string:

### Sync

```csharp
// Request a specific server-wide connection string, pass its name and type:
// =========================================================================
var getOp = new GetServerWideConnectionStringsOperation(
    "ravendb-connection-string-name", ConnectionStringType.Raven);

GetServerWideConnectionStringsResult result = store.Maintenance.Server.Send(getOp);

// Access results:
// ===============
foreach (ServerWideConnectionString serverWideConStr in result.Results)
{
    var name = serverWideConStr.Name;
    var type = serverWideConStr.Type;
    var excludedDatabases = serverWideConStr.ExcludedDatabases;
    
    // The underlying connection string definition:
    var ravenConStr = serverWideConStr.ConnectionString as RavenConnectionString;
}
```

### Async

```csharp
// Request a specific server-wide connection string, pass its name and type:
// =========================================================================
var getOp = new GetServerWideConnectionStringsOperation(
    "ravendb-connection-string-name", ConnectionStringType.Raven);

GetServerWideConnectionStringsResult result = await store.Maintenance.Server.SendAsync(getOp);

// Access results:
// ===============
foreach (ServerWideConnectionString serverWideConStr in result.Results)
{
    var name = serverWideConStr.Name;
    var type = serverWideConStr.Type;
    var excludedDatabases = serverWideConStr.ExcludedDatabases;
    
    // The underlying connection string definition:
    var ravenConStr = serverWideConStr.ConnectionString as RavenConnectionString;
}
```

## Get all server-wide connection strings {#get-all-server-wide-connection-strings}

The following example retrieves all server-wide connection strings defined in the cluster:

### Sync

```csharp
// Get all server-wide connection strings (all types):
// ====================================================
var getAllOp = new GetServerWideConnectionStringsOperation();
GetServerWideConnectionStringsResult result = store.Maintenance.Server.Send(getAllOp);

// Access results:
// ===============    
List<ServerWideConnectionString> allConnectionStrings = result.Results;

foreach (ServerWideConnectionString serverWideConStr in allConnectionStrings)
{
    var name = serverWideConStr.Name;
    var type = serverWideConStr.Type;
    var excludedDatabases = serverWideConStr.ExcludedDatabases;

    // The underlying connection string definition:
    var connectionString = serverWideConStr.ConnectionString;
}
```

### Async

```csharp
// Get all server-wide connection strings (all types):
// ====================================================
var getAllOp = new GetServerWideConnectionStringsOperation();
GetServerWideConnectionStringsResult result = await store.Maintenance.Server.SendAsync(getAllOp);

// Access results:
// ===============        
List<ServerWideConnectionString> allConnectionStrings = result.Results;

foreach (ServerWideConnectionString serverWideConStr in allConnectionStrings)
{
    var name = serverWideConStr.Name;
    var type = serverWideConStr.Type;
    var excludedDatabases = serverWideConStr.ExcludedDatabases;

    // The underlying connection string definition:
    var connectionString = serverWideConStr.ConnectionString;
}
```

## Syntax {#syntax}

```csharp
public GetServerWideConnectionStringsOperation()
public GetServerWideConnectionStringsOperation(
    string connectionStringName, ConnectionStringType type)
```

| Parameter | Type | Description |
| - | - | - |
| **connectionStringName** | `string` | Name of a specific server-wide connection string to retrieve. |
| **type** | `ConnectionStringType` | Connection string type:<br />`Raven`, `Sql`, `Olap`, `ElasticSearch`, `Queue`, `Snowflake`, or `Ai` |

| Operation result | |
| - | - |
| `GetServerWideConnectionStringsResult` | Contains `Results` - a list of the matching server-wide connection strings. |

```csharp
public sealed class GetServerWideConnectionStringsResult
{
    public List<ServerWideConnectionString> Results { get; set; }
}
```

> **Note**
>
> Connection string type-specific fields and complete examples are documented in the task or feature articles listed under
> [Connection string per type](https://docs.ravendb.net/7.2/integrations/connection-strings/per-database/add-or-update-connection-string.md#connection-string-per-type).
