How to get exactly the collections?

Hi all,
I am learning to develop with Mongo driver in C#. I have restricted a user the access to some collections into the database. How can I get the collection names where he can access-> in C# and in the Shell?

the problem is :

var database = client.GetDatabase(DatabaseName); 
 foreach (BsonDocument namecollection in database.ListCollectionsAsync().Result.ToListAsync<BsonDocument>().Result)
                {
                    string name = namecollection["name"].AsString;
                    allcollectionNames.Add(name);
                }

Here the code crash if it encounters a collection where the user doesn’t have right to access

Hello @Markus_Erhardt, welcome to the MongoDB community forum.

You can try this mongo shell method or its equivalent command listCollections.

use someDbName
db.getCollectionInfos( { authorizedCollections : true } )

thank you a lot Prasad_Saya. I am looking for something with C# too. I found that listCollections could do it but where to enter the parameter authorizedcollection ? I founded on AWN some infos

look at page 630

I think you can specify the filter using the ListCollectionsOptions.

Another way is to run the listCollections command using the C# API as shown at Admin Quick Tour → Run a Command.

could you perhaps help me to find the solution. I look everywhere but find nothing.