Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to get the list of domains available on the network. It runs perfectly on my local desktop. But upon deploying, the following error occurred:

Current security context is not associated with an active directory domain or forest.

Any help?

Here is the code i used:
C#
List<string> DomainList = new List<string>();
              var forest = Forest.GetCurrentForest();
              foreach (Domain dm in forest.Domains)
              {
                  DomainList.Add(dm.Name);
              }


Thanks in advance!
Posted
Updated 22-Oct-17 19:37pm
v2

1 solution

Pete O'Hanlon wrote:
Part of the problem you are having here is that your IIS account will probably not be running as a domain account. Have a look at this thread for more information of things to do: http://directoryprogramming.net/forums/thread/1103.aspx[^]

Source[^]
 
Share this answer
 
Comments
[no name] 13-Jul-14 6:39am    
I've already had this error.
It seems that the system that you runs your app isn't a member of current domain.
You once time run your app on the system that member of domain and checked that this error occured or no

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900