Directory Programming .NET

Active Directory and ADAM programming support for .NET developers
Welcome to Directory Programming .NET Sign in | Join | Help
in Search

Error on this code

Last post 09-05-2008, 11:55 AM by m2m. 23 replies.
Page 2 of 2 (24 items)   < Previous 1 2
Sort Posts: Previous Next
  •  09-02-2008, 11:33 AM 4570 in reply to 4567

    Re: Error on this code

    where do i get this utility???
  •  09-02-2008, 1:33 PM 4575 in reply to 4567

    Re: Error on this code

    It comes with ADAM, so that's one easy way to get it.  I think it comes with either the Windows support tools or the admin pack as well.  I can't remember which one.  It is probably already installed on your domain controllers.
  •  09-03-2008, 9:18 AM 4585 in reply to 4575

    Re: Error on this code

    Got it thanks should provide alot of uselful info I will let you know, for know it looks like i need to "bind" to the domain controlers ???

     

    Thanks

  •  09-03-2008, 9:34 AM 4586 in reply to 4585

    Re: Error on this code

    There is plenty of online help for LDP on technet.  Just search for it.

    Yes, you do need to bind (authenticate) to a domain controller in order to do searches.  If you are logged in with your domain account when using the tool, you can use null credentials.  Otherwise, you need to specify a username and password. 

  •  09-04-2008, 2:04 PM 4602 in reply to 4586

    Re: Error on this code

    I finally was able to bind and get the info i needed,,, a little slow but operational with the following:

    is there anyway to speed up the process??? and number 2 how can i sort the items going into the list box with the folloowing code:

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    For Each user As ADODSUser In Form1.GetUsers()

    Me.ListBox1.Items.Add(user.Name)

    Next

    End Sub

     

    Public Shared Function GetUsers() As List(Of ADODSUser)

    Dim users As New List(Of ADODSUser)

    Dim defaultNamingContext As String

    Using rootDSE As New DirectoryEntry("LDAP://RootDSE")

    defaultNamingContext = rootDSE.Properties("defaultNamingContext").Value.ToString()

    End Using

     

    Dim SearchRootADsPath As String = [String].Format("LDAP://OU=HYHCUsers,OU=HYHC,DC=Ministryhealth,DC=net", defaultNamingContext)

    Using searchRoot As New DirectoryEntry(SearchRootAdsPath)

    Using ds As New DirectorySearcher(searchRoot)

    ds.Filter = "(&(objectClass=user)(objectCategory=person))"

    ds.SearchScope = SearchScope.Subtree

    ds.PageSize = 1000

    Using src As SearchResultCollection = ds.FindAll()

    For Each sr As SearchResult In src

    users.Add(New ADODSUser(sr.Properties("samAccountName")(0).ToString(), sr.Properties("distinguishedName")(0).ToString()))

    Next

    End Using

    End Using

    End Using

    Return users

    End Function

  •  09-04-2008, 2:56 PM 4604 in reply to 4602

    Re: Error on this code

    You can reduce the amount of data on the wire by adding sAMAccountName to the PropertiesToLoad on the DirectorySearcher.  Since you only read that, you might as well only bring that back.

    For search, I suggest you call Sort on your List<T>.  I think you may need to implement IComparable on your ADODSUser class though.

  •  09-04-2008, 3:06 PM 4606 in reply to 4604

    Re: Error on this code

    could you elaborate a litte bit please ???? Acronynms ??

    Sorry, thanks alot

  •  09-04-2008, 3:40 PM 4607 in reply to 4606

    Re: Error on this code

    I don't know which acronyms you are referring to.  However, sorting is basically done by calling the Sort method on your List<T> instance.

    The effort on your part is to implement the property interface on your T type (ADODSUser) so that the list can be sorted.  You can either implement IComparable(of T) interface or the IComparable interface.  Just read the .NET docs to see what you need to do to implement that.  It isn't hard and will probably come down to doing string comparisons.

    This isn't really a forum for basic .NET programming tasks, so you might need to look to other resources for more info on basic sorting stuff.  The MSDN docs are fine here.

  •  09-05-2008, 11:55 AM 4616 in reply to 4607

    Rreseting user password and unlocking account

    With the following code snippet what more do i need , i simply want to change a users password

    as it stands i get vb compile errors DirectoryEntry cannot be used as expresseio,uEntry niot declared, this is invalid ";"

    thanks

    DirectoryEntry uEntry = New DirectoryEntry(user);

    uEntry.Invoke("Setpassword",new object[]{"Summer08"}

    uEntry.Properties["LockOutTime"].Value=0;

    uEntry.Close();

     

    i am using this code snippet in another function, prior to this i have bound with our AD controller, and populated a listbox with the users names, here i get the users name(user) and am trying to reset their password. SO i have a bind to AD prior to this if that helps at all with the following:

    Dim users As New List(Of ADODSUser)

    Dim String1 As String = "LDAP://OU=HYHCUsers,OU=HYHC,DC=Ministryhealth,DC=net"

    Dim defaultNamingContext As String

    Using rootDSE As New DirectoryEntry("LDAP://RootDSE")

    defaultNamingContext = rootDSE.Properties("defaultNamingContext").Value.ToString()

    End Using

Page 2 of 2 (24 items)   < Previous 1 2
View as RSS news feed in XML