Set objCon = Server.CreateObject("ADODB.Connection")
Set objCommand = Server.CreateObject("ADODB.Command")'--- Setting Connection parameter ---
objCon.Provider = "ADsDSOObject"
objCon.Properties("User ID") = ADMIN_USER
objCon.Properties("Password") = ADMIN_PASSWD
objCon.Properties("Encrypt Password") = True
objCon.Provider = "ADsDSOObject"
objCon.OpenstrSQL = "SELECT AdsPath FROM 'LDAP://gend.pst.local/OU=gend root,DC=gend,DC=pst,DC=local' WHERE objectClass = 'user' AND samAccountName='" & searchaccount & "'"
objCommand.CommandText = strSQL
objCommand.Properties("searchscope") = 2
objCommand.Properties("Cache Results") = False
objCommand.CommandType = 1Set objRecordSet = objCommand.Execute
Set objCommand = Server.CreateObject("ADODB.Command")'--- Setting Connection parameter ---
objCon.Provider = "ADsDSOObject"
objCon.Properties("User ID") = ADMIN_USER
objCon.Properties("Password") = ADMIN_PASSWD
objCon.Properties("Encrypt Password") = True
objCon.Provider = "ADsDSOObject"
objCon.OpenstrSQL = "SELECT AdsPath FROM 'LDAP://gend.pst.local/OU=gend root,DC=gend,DC=pst,DC=local' WHERE objectClass = 'user' AND samAccountName='" & searchaccount & "'"
objCommand.CommandText = strSQL
objCommand.Properties("searchscope") = 2
objCommand.Properties("Cache Results") = False
objCommand.CommandType = 1Set objRecordSet = objCommand.Execute
解决方案 »
- 谁有 BMP -> Gif 的源代码? 谁有 BMP -> Gif 的源代码?
- 请问如果我获得了一个打开的文件句柄,我怎么通过这个句柄获得文件的信息,例如文件的路径?
- CString 型怎么样向DateTimePicker控件写入值?
- 怎么让有位图背景的对话框上的static控件的背景为透明的?
- 如何向局域网内计算机的共享目录copy文件? 知道用户名与密码。
- 初学者的问题
- 谁试过把数据库连接加操作封装过COM,有源代码的更好学习学习
- 在vc中unsigned short int 和char*如何实现转换!
- 谁知道如何在程序中检测一个Foxpro表是否可以以独占的方式打开?再加100分.
- 烦!散分!!!
- 脱下军装,散分
- 机内码
_CommandPtr pCommand("ADODB.Command");
_RecordsetPtr pRs("ADODB.Recordset");
_ConnectionPtr pConn("ADODB.Connection" );
_CommandPtr pCommand("ADODB.Command"); CString strPri,strSQL; strSQL = "SELECT AdsPath FROM 'LDAP://gend.pst.local/OU=gend root,DC=gend,DC=pst,DC=local' WHERE objectClass = 'user' AND samAccountName=' " &searchaccount& " ' "; strPri = strPri +
"Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source = ADsDSOObject " +
";Persist Security Info=False;Jet OLEDB:Database Password = ADMIN_PASSWD User ID = ADMIN_USER;"; pCommand->CommandText = (_bstr_t)strSQL; try
{
pConn->Open((_bstr_t)strSql, "", "", adModeUnknown);
pCommand.CreateInstance(__uuidof(Command));
pCommand->Execute(NULL, NULL, adCmdText);
}
catch(...)
{}
#import "c:\...\msado15.dll" using_namespace("ADODC")
并且把msado15.dll拷贝到system32下了但是引用
IADORecordBinding *picRs = NULL;
_RecordsetPtr pRs("ADODB.Recordset");
_ConnectionPtr pConn("ADODB.Connection" );
_CommandPtr pCommand("ADODB.Command");
的时候 还是说我没有定义
#include <basetsd.h>
#include <ole2.h>#import "c:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")
先说一句:请容忍菜鸟!请问一下strSQL这个变量应该放在哪里?我要实现的功能是从域的系统数据库中取得用户的mail和真名。对于vc我是个菜鸟,这个功能用asp已经实现了,转到vc中,请大家言无不尽呀!
asp代码如下<%
Const ADMIN_USER = "ps\Administrator"
Const ADMIN_PASSWD = "dfgdfg"
%><%
Dim time1,time2 time1 = timer Call Test("jo")
Call Test("pf72319")
Call Test("asagi")
Call Test("advice")
Call Test("mmva58z")
Call Test("mcp2e1")
Call Test("mr5t4diz")
Call Test("mh8jnm")
Call Test("xuli13")
Call Test("md3zk") time2 = timer response.write time2-time1%><%
Sub Test (searchaccount)Dim objCon '--- ConnectionObject
Dim objCommand '--- CommandObject
Dim objRecordSet '- RecordsetObject
Dim objError '--- ErrorObject
Dim objData '--- For Get DataDim strSQL '--- SQL string
Dim strError '--- Error string'--- Set up the connection ---
Set objCon = Server.CreateObject("ADODB.Connection")
Set objCommand = Server.CreateObject("ADODB.Command")'--- Setting Connection parameter ---
objCon.Provider = "ADsDSOObject"
objCon.Properties("User ID") = ADMIN_USER
objCon.Properties("Password") = ADMIN_PASSWD
objCon.Properties("Encrypt Password") = True
objCon.Provider = "ADsDSOObject"
objCon.Open '--- connenct ---Set objCommand.ActiveConnection = objCon'--- Execute the query for the user in the directory ---
strSQL = "SELECT AdsPath FROM 'LDAP://gend.pst.local/OU=gend root,DC=gend,DC=pst,DC=local' WHERE objectClass = 'user' AND samAccountName='" & searchaccount & "'"
objCommand.CommandText = strSQL
objCommand.Properties("searchscope") = 2
objCommand.Properties("Cache Results") = False
objCommand.CommandType = 1On Error Resume Next ' --- Execute SQL
Set objRecordSet = objCommand.Execute
'//
If objCon.Errors.Count > 0 Then
For Each objError In objCon.Errors
strError = strError & "Error #" & Hex(objError.Number) & "<BR>" & _
" " & objError.Description & "<BR>" & _
"NativeError:" & Hex(objError.NativeError) & "<BR>" & _
"SQLState:" & objError.SQLState & "<BR>" & _
"Reported by:" & objError.Source & "<BR>" & _
"Help file:" & objError.HelpFile & "<BR>" & _
"Help Context ID:" & objError.HelpContext
Next
response.Write strError
End If' ---Display Search Result ---' Debug
'response.Write "結果= " & objRecordSet.RecordCount & "(" & objRecordSet.Fields.Count & ")<BR>"For i = 0 To oRecordSet.RecordCount - 1
' Debug
' response.Write objRecordSet.Fields.item("AdsPath") & "<BR>"' --- Getting Data ---
Set objData = GetObject(objRecordSet.Fields.item("AdsPath"))
username = objData.Get("cn")
usermail = objData.Get("mail") ' --- Display Data ---
response.Write "氏名:" & username & "<BR>"
response.Write "Mail:" & usermail & "<BR>" Set objData = Nothing objRecordSet.MoveNext
Next' -- Clean up --
objRecordSet.Close
objCon.Close
Set oRecordSet = Nothing
Set objCommand = Nothing
Set objCon = NothingEnd Sub
%>