AD-Login

badblueboy

Member
Joined
Mar 12, 2007
Messages
7
Programming Experience
Beginner
hi @ll,

I'm new here so - Greetings!
I'm from Switzerland so sorry for my pretty bad english in advance.

Also I'm pretty new in the thematic VB.Net, so that some questions could be n00bish...

Here's my problem:
I'm programming an application for the Active Directory-administrators in our company. Till now they always worked directly in the AD to edit a user, create a new one and so on. I'm trying to give them the opportunity that they can do the same in the webbrowser.

Till now it's looking pretty good, but now I'm stucked:
With the following code I'm searching in the AD a user with the right username and password:
VB.NET:
Expand Collapse Copy
    Public Sub ADSLoginRead()

        Dim dirSearcher As New DirectorySearcher
        Dim dirResult As SearchResult

        Try
            dirSearcher = New DirectorySearcher(New DirectoryEntry(mstrADSConnectionString, mstrUserID, mstrKennwort))

            dirSearcher.Filter = "(objectClass=user)"
            If Len(mstrUserID) > 0 Then
                dirSearcher.Filter = "(&" & dirSearcher.Filter & "(samaccountname=" & mstrUserID & "))"
            End If

            mdirSearchResultat = dirSearcher.FindAll()


        Catch ex As Exception
            Select Case Err.Number
                Case -2147023570
                    mdirSearchResultat = Nothing
                Case Else
                    Err.Raise(Err.Number, Err.Source, Err.Description, Err.HelpFile, Err.HelpContext)
            End Select
        Finally
            dirSearcher = Nothing
        End Try

    End Sub
Then
VB.NET:
Expand Collapse Copy
        If IsNothing(mobjDaActiveDirectory.dirSearchResultat) OrElse mobjDaActiveDirectory.dirSearchResultat.Count = 0 Then
            mbolLoginResult = False
        Else
            mbolLoginResult = True
        End If
So far, it WORKS.

BBBBBBUT, now that the AD found such a user (which should be the administrator), how can I edit a user and so on? Somehow I have to do a "real login" so that I can edit users, or not?

I already have a formular for editing users etc., but I don't get it how I can edit now a user because I'm not logged in, right?

I would be very thankful if anyone could help me...


greets BBB
 
Back
Top