Get layer datasource without using Workspace

1022
0
05-09-2017 12:12 AM
MU
by
New Contributor III

Hi,

how can I retrieve the information that the data source of a layer is either a SDE or any other spatial database (Oracle, SQL Server) without using this if the user is not authorized:

(IDataset(myLayer)).Workspace.Type‍

Background: I have a small command line application written in C# that iterates over the layers of a MXD and gather all data sources that are located within a File Geodatabase.

To distinguish between File Geodatabase, SDE and spatial database, I use a combination of (IDataset(myLayer)).Workspace.Type and (IDataset(myLayer)).Category, which works fine.

When my application runs under a user who is not authorized to access the layer, (IDataset(myLayer)).Workspace throws a COM-Exception saying that get_workspace() cannot be executed which seems reasonable because the user has no permissions.

When opening the MXD with the not authorized user in ArcMap, I see the red exlamation marks indicating the layers that cannot be accessed, but when opening the layer properties, I can see basic information like type (e. g. 'XY Event Source') and path (e. g. 'myDatabaseServer\MyDatabaseInstance'). That's exactly the information I'd like to get in my application, but how can I do this without using (IDataset(myLayer)).Workspace which throws an exception?

Thanks!

0 Kudos
0 Replies