CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 1999
    Posts
    226

    Issues With Using DirectoryEntry.Invoke()

    While researching how to write a program to interface with Active Directory I read that Inoke() can only be called once per program execution. It seemed unlikely that was true so I coded my program to simply call Invoke() whenever I needed. Mostly for setting a password or adding a user to a group. It worked but I had stability issues. Mainly I would get MDA errors. Usually it was the one that says 'ContextSwitchDeadlock was detected'. I read that this is caused by a process not responding to window messages. Does Invoke() start up a thread that doesn't go away? Should I write code that kills this thread after Invoke() returns?

    What I read suggested that I write a small program that simply calls Invoke() and returns. So I wrote a program that does that and I call it with this code

    Code:
    Dim info As ProcessStartInfo = New ProcessStartInfo
    info.FileName = "D:\Custom Programs\ADCommandInvoker"
    info.Arguments = "ADPath|""" + group.Path + """ ADCommand|Add" + " ADParameter|""" + deUser.Path + """"
    info.CreateNoWindow = True
    info.UseShellExecute = False
    
    Dim invoker As Process = Process.Start(info)
    invoker.WaitForExit()
    My program does seem to run better like this. Can someone tell me if it is worth doing it like this? I read that MDA messages go away when the program is not run from the debugger. So I suspect I should just call Invoke().

    The goal of this program is to take our list of active students make sure they all have an active directory account, disable accounts for students who are no longer active, create a network drive for eash student, verify their active directory settings are correct, and to verify their network drive permissions are correct.

    Currently, this program takes 30-45 minutes to process about 3400 students. My helper program is called about once per student. If I can simply call Invoke() I suspect the processing time will drop a lot.

    I want this to work as a job the runs nightly. Random error message or failures will make this impossible.

    I know I have a lot of questions. Can someone at least answer most of them?


    Thanks,
    Scott

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Issues With Using DirectoryEntry.Invoke()

    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured