I'd like to learn HOW TO CHECK AUTHENTICATION OF USER IN VISUAL BASIC, it
would be great if anyone can tell me the syntax of query string.
Following codes is success when I use it in ASP:
'***************************************************************************
Sub AuthCheck(ByVal HavingInput)
Dim RootDSE
Dim DSObject
Dim Auth
Dim NamingContext
Const ADS_SECURE_AUTHENTICATION=1
Set RootDSE = GetObject("GC://rootDSE")
NamingContext = RootDSE.Get("defaultNamingContext")
Set DSObject = GetObject("GC:")
Set Auth = DSObject.OpenDSObject("GC://" & NamingContext, sUser, sPassword,
ADS_SECURE_AUTHENTICATION)
If err = 0 then
Response.Redirect("grant.asp")
Else
Response.Redirect("fail.asp")
End If
Set Auth = Nothing
Set DSObject = Nothing
Set RootDSE = Nothing
End Sub
'***************************************************************************
I modified wonder what should be the query string "strQuery" in the
following Visual Basic Codes:
'***************************************************************************
Public Function UserInfo(LoginName As String) As String
Dim conn As New ADODB.Connection
Dim rs As ADODB.Recordset
Dim oRoot, oDomain As IADs
Dim strBase, strFilter, strDomain As String
Dim strAttribs, strDepth, strQuery As String
Dim strQuery, strAns As String
Dim user As IADsUser
On Error GoTo ErrUserInfo:
Set oRoot = GetObject("GC://intern.company.com/rootDSE")
strDomain = oRoot.Get("defaultNamingContext")
Set oDomain = GetObject("GC:")
strBase = "GC://intern.company.com"
strBase = strBase & "/" & strDomain
strAttribs = "adsPath"
strDepth = "subTree"
strFilter = "User ID=testacc"
strQuery = strBase & "," & strFilter & "," & strAttribs & "," & sDepth &
",Encrypt Password= True,ADSI Flag= ADS_SECURE_AUTHENTICATION"
conn.Open _
"Data Source=Active Directory Provider;Provider=ADsDSOObject"
Set rs = conn.Execute(strQuery)
If Not rs.EOF Then
Set user = GetObject(rs("adsPath"))
With user
strAns = "First Name: " & .FirstName & vbCrLf
strAns = strAns & "Last Name " & .LastName & vbCrLf
strAns = strAns & "Email Address: " & .EmailAddress & vbCrLf
strAns = strAns & "Last Login: " & .LastLogin & vbCrLf
strAns = strAns & "Last Logoff: " & .LastLogoff & vbCrLf
End With
End If
UserInfo = strAns
ErrUserInfo:
If Not rs Is Nothing Then
If rs.State <> 0 Then rs.Close
Set rs = Nothing
End If
If Not conn Is Nothing Then
If conn.State <> 0 Then conn.Close
Set conn = Nothing
End If
Set oRoot = Nothing
Set oDomain = Nothing
End Function
'***************************************************************************
Thanks all in advance,
Pong Wong
Actually I'd like to bound the access of my application by the
authentication of AD, simply return True / False just like my ASP version.
However, there seem no "OpenDSObject" in VB, moreover, it return "Table does
not exist." after I modified the sample codes from
"http://www.freevbcode.com/ShowCode.Asp?ID=710".
Is there any function like "OpenDSObject" in VB?
How can I output the structure of the AD of a server by my WinXP PC for
further information?
Thanks for your reponse,
Pong Wong
The main problem I faces is that the AD tree structure of the server seemed
not to be the same as the demo in
"http://www.freevbcode.com/ShowCode.Asp?ID=710".
i.e. the "strQuery" not valid for me to get the account information. It
returns "one or more error..."
Is there any way that I can output the tree structure of the server?
Thanks in advance,
Pong Wong
How can I use the Authenticating Services in my VB6 application as it works
in ASP as follows:
"DSObject.OpenDSObject("GC://" & NamingContext, sUser, sPassword,
ADS_SECURE_AUTHENTICATION)"
THanks a lot,
Pong Wong
Thanks for your reply and I'll try.
Pong Wong
Yeah! That work! Thank you very much.
However, during debugging, I have another question:
"How can I output the structure of the AD of a server by my WinXP PC? (As I
don't know the structure even the name of the OUs)"
Thanks again.
Pong Wong
Need help.
regards
Raza Usmani