none
Domain.GetDirectoryEntry is taking long time for off domain RRS feed

  • Question

  • Hi Experts,

    We have a forest domain where we have few child domains. Some times few of our domains get down at that time, execution of domain.GetDirectoryEntry() is taking long time (around 18-20 secs). Is there any alternative to reduce the time-spam for determining whether domain is up or down?

    Wednesday, September 25, 2013 8:12 AM

Answers

  • Hi Shailendra,

    I’m sorry to tell you that there is no way to reduce the execution time of domain.GetDirectoryEntry method. The Domain class hasn’t have TimeOut property and something about Asynchronous methods. So I think you should keep network unimpeded for good performance.

    http://msdn.microsoft.com/en-us/library/System.DirectoryServices.ActiveDirectory.Domain.aspx

    One possible way to get around this issue is to get the domain list of the foreast and see if the target domain exists in the list. Like:

    var myDomain = Domain.GetComputerDomain();
    var forestDomains = myDomain.Forest.Domains;
    bool bexist = false;
    foreach(Domain d in forestDomains)
    {
       if(d.Name.ToLower() == targetDomainName.ToLower())
       {
          bexist = true;
          break;
       }
    }
    

    Best Regards,

    Hetro



    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Thursday, September 26, 2013 7:14 AM
    Moderator
  • Hi Shailendra,

    Unfortunately I think there is no real other way. Just think about how you verify that an IP address is reachable. All you can do is try a connection or send a ping request. After this you just have to wait if someone will answer and due to the fact that the connection could be slow the timeouts are high and you have to wait all the time.

    All you can do for a better user experience is to put this job into another tread (or background worker) so that your GUI is still responsive and showing some progress or marquee bar to the user. Then you could also add the possibility for the user to cancel the connection tryout by simply aborting this thread.

    So this wouldn't make it any faster but give a better responsive to the user and so it feels faster at last.

    Best Regards,

    Hetro


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Wednesday, October 2, 2013 3:39 AM
    Moderator

All replies

  • Hi Shailendra,

    I’m sorry to tell you that there is no way to reduce the execution time of domain.GetDirectoryEntry method. The Domain class hasn’t have TimeOut property and something about Asynchronous methods. So I think you should keep network unimpeded for good performance.

    http://msdn.microsoft.com/en-us/library/System.DirectoryServices.ActiveDirectory.Domain.aspx

    One possible way to get around this issue is to get the domain list of the foreast and see if the target domain exists in the list. Like:

    var myDomain = Domain.GetComputerDomain();
    var forestDomains = myDomain.Forest.Domains;
    bool bexist = false;
    foreach(Domain d in forestDomains)
    {
       if(d.Name.ToLower() == targetDomainName.ToLower())
       {
          bexist = true;
          break;
       }
    }
    

    Best Regards,

    Hetro



    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Thursday, September 26, 2013 7:14 AM
    Moderator
  • Thanks Hetro,

    But i have one concern, i don't have any targetDomain, actually i don't know which domain will be down.

    Since, i am using domainSearcher to search users i have to add each domain in forest, but if some domains (not-known earlier) are down, i won't be able to determine which one got down. At the time of execution when we encounter domain.GetDirectoryEntry(), is taking time for domain which is down.

    Thanks,

    Shailendra

    Friday, September 27, 2013 11:42 AM
  • Hi Shailendra,

    Unfortunately I think there is no real other way. Just think about how you verify that an IP address is reachable. All you can do is try a connection or send a ping request. After this you just have to wait if someone will answer and due to the fact that the connection could be slow the timeouts are high and you have to wait all the time.

    All you can do for a better user experience is to put this job into another tread (or background worker) so that your GUI is still responsive and showing some progress or marquee bar to the user. Then you could also add the possibility for the user to cancel the connection tryout by simply aborting this thread.

    So this wouldn't make it any faster but give a better responsive to the user and so it feels faster at last.

    Best Regards,

    Hetro


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Wednesday, October 2, 2013 3:39 AM
    Moderator