没有登录凭据的LDAP身份验证VB6

时间:2015-04-15 19:45:56

标签: vb6 active-directory ldap vb.net-2010

我创建了一个用户身份验证的VB6程序。但是相同的身份验证在服务器上使用LDP.exe,它允许用户使用登录凭据,也没有凭据。但是当我尝试使用客户机(XP)时,它说:

  

域名不存在。

Dim objGroup As IADsGroup
Dim strDN As String
Dim adsSystemInfo As IADsADSystemInfo
strDN = "CN=Users,dc=DomainName,dc=Net"
Set objGroup = GetObject("LDAP://" & strDN)
Set adsSystemInfo = CreateObject("ADSystemInfo")

1 个答案:

答案 0 :(得分:0)

在项目中引用activeds.tlb。用法:

 With New ADSystemInfo
  MsgBox ("Computer Name: " & .ComputerName)
  MsgBox ("User Name: " & .UserName)
 End With

您还可以使用ADO查询LDAP对象,例如:

Dim oConn As New ADODB.Connection
Dim oRS As New ADODB.Recordset
Dim oField As ADODB.Field
Dim iP As IADs

oConn.Provider = "ADsDSOObject"
oConn.CursorLocation = adUseNone
oConn.Open "Active Directory Provider"

oRS.CursorLocation = adUseClient
oRS.Open "Select * from 'LDAP://domain'", oConn, adOpenStatic, adLockReadOnly

Set iP = GetObject(oRS(0).Value)

While Not oRS.EOF
 For Each oField In oRS.Fields
  List1.AddItem oField.Name & " / " & oField.Value
 Next

 oRS.MoveNext
Wend

oRS.Close
Set oRS = Nothing