Retrieve members of group for each server specified - Error: Network path was not found

venkatesh padmanabhan 181 Reputation points
2020-09-30T15:58:19.103+00:00

Hi.
I am using scripttask in SSIS to retrieve the members of a group from each of server.

I used the below code:

  DirectoryEntry deComputer = new DirectoryEntry("WinNT://" + ComputerName + ",computer");
                deComputer.RefreshCache();

                DirectoryEntry deGroup = deComputer.Children.Find(groupName, "group");
                Object Members = deGroup.Invoke("Members", null);                 

        

The above code works , when i run on the server which has this code. If i input a different server within the same domain, I am getting error as - Network path was not found.

How to fix this?
Thanks

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,067 questions
SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,486 questions
0 comments No comments
{count} votes

Accepted answer
  1. venkatesh padmanabhan 181 Reputation points
    2020-09-30T16:55:34.097+00:00

    Hi.

    Found the solution with the below code:

    var server = new DirectoryEntry(string.Format("WinNT://{0},Computer", machine));
    
    DirectoryEntry group = server.Children.Cast<DirectoryEntry>().Where(
    
        d => d.SchemaClassName.Equals("Group") && d.Name.Equals("Group Name")
    
    ).Single<DirectoryEntry>();
    

    Got from: https://stackoverflow.com/questions/25060655/c-sharp-principalcontext-the-network-path-was-not-found

    Thanks


0 additional answers

Sort by: Most helpful