Hello,
I'm trying very (too) hard to log uses LDAP (via ADSI) to autheniticate
users in an A2k2 application. We have AD and I have that working
slick. We are in a tranistion from NDS to AD and I would like to get
the NDS side working during the transition. I know the concept of what
required
Microsoft's information is very sparse and incomplete if not wrong.
1) What would the provider be (and how do we know if I/others have it)
2) What's require in the commandtext (some say LDAP://.. other say
NDS://.. neither work)
3) I'm assuming the context in required with user name but in what
format?
4) What is the ASDI flag?
Keep in mind this code only works on the AD side (txtService = "AD").
This code (with a blank txtService) gives me a "Table does not exist"
error. What table?
__________________________________________
private sub testlogin
Dim con As New Connection, rs As New Recordset, txtService As String
Dim adVariant
Dim i, j 'Used for counter
Dim Com As New Command
Dim strDomain, strPassword, strAttributeList, txtCommandText As String
'On Error GoTo Err_ThisSub
' Open a Connection object.
con.Provider = "ADsDSOObject"
con.Properties("ADSI Flag") = 1
txtService = ""
If txtService = "AD" Then
strAttributeList =
"sAMAccountname,displayName,distinguishedname,memb erOf"
con.Properties("User ID") = "ad\" & Me.txtUserName
con.Properties("Password") = Me.txtPassword
con.Open "Active Directory Provider"
txtCommandText =
"<LDAP://servername/OU=x,OU=y,DC=z,DC=a>;(sAMAccountname=" &
Me.txtUserName & ");" & strAttributeList & ";subtree"
Else
strAttributeList =
"dn,cn,fullname,givenname,groupmembership,employee number,mail"
con.Properties("User ID") =
"cn=username,ou=User,ou=y,o=z"
con.Properties("Password") = Me.txtPassword
con.Open "NDS Provider"
txtCommandText =
"<LDAP://servername/cn=userid,ou=b,o=a>;(cn=marc1tim);"
& strAttributeList & ";subtree"
End If
' Create a command object on this connection.
Set Com.ActiveConnection = con
Com.CommandText = txtCommandText
' Set search preferences.
Com.Properties("Page Size") = 1000
Com.Properties("Timeout") = 30 'seconds
' Execute the query.
Set rs = Com.Execute
' Navigate the record set.
rs.MoveFirst
Me.txtOutput = Null
While Not rs.EOF
For i = 0 To rs.Fields.Count - 1
If rs.Fields(i).Type = vbVariant And Not
(IsNull(rs.Fields(i).Value)) Then
For j = LBound(rs.Fields(i).Value) To
UBound(rs.Fields(i).Value)
Me.txtOutput = Me.txtOutput & rs.Fields(i).Name & " : "
& CStr(rs.Fields(i).Value(j)) & vbCr & vbLf
Next j
Else
Me.txtOutput = Me.txtOutput & rs.Fields(i).Name & " : " &
rs.Fields(i).Value & vbCr & vbLf
End If
Next i
rs.MoveNext
Wend
rs.MoveLast
rs.Close
Set rs = Nothing
Exit_ThisSub:
Exit Sub
Err_ThisSub:
MsgBox Err.Number & ": " & Err.Description, , "Login Error"
Resume Exit_ThisSub
End Sub