Split errors - object not found and unknown error

Answered Split errors - object not found and unknown error

  • Wednesday, May 09, 2012 7:12 PM
     
      Has Code

    I have the code below giving me grief because it gives unknown error (0x80005000) when trying to add a user to a second group:

          

     AD = New DirectoryEntry(Trim("LDAP://OU=Topou,OU=Staff,DC=garrard,DC=ketsds,DC=net"), "", "", AuthenticationTypes.Secure)
                    AD2 = New DirectoryEntry(Trim("LDAP://OU=_Exchange Resources,OU=Staff,DC=garrard,DC=ketsds,DC=net"), "", "", AuthenticationTypes.Secure)
                    ADFind = New DirectorySearcher(AD)
                    groupname = "Lancaster Elementary Teachers"
                    group = AD2.Children.Find("CN=" + Trim(groupname))
                    ' ADFind.Filter = ""
                    'results = Nothing
                    ' Add a single user to a group; 
                    ADFind.Filter = "(&(objectCategory=user)(cn=" + userID + "))"
                    results = ADFind.FindOne
                    DN = results.Properties("distinguishedName").Item(0).ToString()
                    group.Properties("member").Add(DN)
                    group.CommitChanges()

    Also, I have another error in the same code block which is the same sub that gives me a completely different error - their is no such object on the server:

     Dim results1 As SearchResult
                    AD = New DirectoryEntry("LDAP://OU=TopOu,OU=Staff,DC=garrard,DC=ketsds,DC=net", "", "", AuthenticationTypes.Secure)
                    AD2 = New DirectoryEntry("LDAP://OU=_Exchange Resources,OU=Staff,DC=garrard,DC=ketsds,DC=net", "", "", AuthenticationTypes.Secure)
                    ADFind = New DirectorySearcher(AD)
                    ADFind.Filter = ""
                    groupname = "Garrard Co MS Teachers"
                    ADFind.Filter = "(&(objectCategory=user)(cn=" + userID + "))"
                    group = AD2.Children.Find("CN=" + groupname)
                    ' Add a single user to a group; 
                    results1 = ADFind.FindOne
                    DN = results.Properties("distinguishedName").Item(0).ToString()
                    group.Properties("member").Add(DN)
                    group.CommitChanges()

                                                                                                                          


    Once you eliminate the impossible, whatever remains, no matter how improbable, must be the truth. - "Sherlock holmes" "speak softly and carry a big stick" - theodore roosevelt. Fear leads to anger, anger leads to hate, hate leads to suffering - Yoda. Blog - http://jefferycarlsonblog.blogspot.com/



    • Edited by The Thinker Wednesday, May 09, 2012 7:12 PM
    • Edited by The Thinker Wednesday, May 09, 2012 7:13 PM
    •  

All Replies

  • Wednesday, May 09, 2012 7:13 PM
     
     
    P.S. left in the bottom ou parts so no-one got confused when helping me because its a little structured.

    Once you eliminate the impossible, whatever remains, no matter how improbable, must be the truth. - "Sherlock holmes" "speak softly and carry a big stick" - theodore roosevelt. Fear leads to anger, anger leads to hate, hate leads to suffering - Yoda. Blog - http://jefferycarlsonblog.blogspot.com/

  • Wednesday, May 09, 2012 7:37 PM
     
     

    Also, the trim statements seem to be not affecting the error from still popping up because i tryed it without trim statements and same errors on both code sections.


    Once you eliminate the impossible, whatever remains, no matter how improbable, must be the truth. - "Sherlock holmes" "speak softly and carry a big stick" - theodore roosevelt. Fear leads to anger, anger leads to hate, hate leads to suffering - Yoda. Blog - http://jefferycarlsonblog.blogspot.com/


    • Edited by The Thinker Wednesday, May 09, 2012 7:39 PM
    •  
  • Thursday, May 10, 2012 12:34 PM
     
     
    No ideas on at least one of the errors?

    Once you eliminate the impossible, whatever remains, no matter how improbable, must be the truth. - "Sherlock holmes" "speak softly and carry a big stick" - theodore roosevelt. Fear leads to anger, anger leads to hate, hate leads to suffering - Yoda. Blog - http://jefferycarlsonblog.blogspot.com/

  • Thursday, May 10, 2012 2:40 PM
     
     Answered

    Update: got the unknown error to disappear by including the ip address in the query in first post but not the no such object on server error. heres the full query excluding the topou:

    "LDAP://10.253.97.10/OU=Topou,OU=Staff,DC=garrard,DC=ketsds,DC=net"

    splitting the no such object into another thread.


    Once you eliminate the impossible, whatever remains, no matter how improbable, must be the truth. - "Sherlock holmes" "speak softly and carry a big stick" - theodore roosevelt. Fear leads to anger, anger leads to hate, hate leads to suffering - Yoda. Blog - http://jefferycarlsonblog.blogspot.com/



    • Edited by The Thinker Thursday, May 10, 2012 2:43 PM
    • Marked As Answer by The Thinker Thursday, May 10, 2012 4:55 PM
    • Edited by The Thinker Thursday, May 10, 2012 4:55 PM
    •  
  • Monday, May 14, 2012 5:46 AM
    Moderator
     
     

    Cheers!

    Best regards,


    Shanks Zen
    MSDN Community Support | Feedback to us