VFP 愛用者社區 首頁 VFP 愛用者社區
本討論區為 Visual Foxpro 愛用者經驗交流的地方, 請多多利用"搜尋"的功能, 先查看看有無前例可循, 如果還有不懂的再發問. 部份主題有附加檔案, 須先註冊成為社區居民才可以下載.
 
 常見問題常見問題   搜尋搜尋   會員列表會員列表   會員群組會員群組   會員註冊會員註冊 
 個人資料個人資料   登入檢查您的私人訊息登入檢查您的私人訊息   登入登入

Ad user問題

 
發表新主題   回覆主題    VFP 愛用者社區 首頁 -> VFP 討論區
上一篇主題 :: 下一篇主題  
發表人 內容
nelsonchuang



註冊時間: 2003-09-04
文章: 563
來自: 臺灣

第 1 樓

發表發表於: 星期五 四月 11, 2008 4:44 pm    文章主題: Ad user問題 引言回覆

我想請問一下,有沒有人用Vfp轉出Ad user資料過.
Ad->Active Directory
說明:其實在Erp,或是電子表單,可能你們有使用者或是主管要求
你的帳號跟密碼可以跟登入電腦時的一樣,也就是單一登入.
Single Sign on,
通常,我們是會說服使用者,不要這樣子辦,因為可能因此門戶洞開.
但也有可能你的主管或是使用者很強勢,希望可以辦到.
所以...我才會提這個問題...

雖然我已用c#辦到了.(因為網路上用力找就有)
但是我還是想知道有沒有人用vfp辦到過,可不可以指導一下,也順便造福
其他的同學...謝謝~

_________________
大家好,請多指教
回頂端
檢視會員個人資料 發送私人訊息
nelsonchuang



註冊時間: 2003-09-04
文章: 563
來自: 臺灣

第 2 樓

發表發表於: 星期一 四月 14, 2008 9:33 am    文章主題: 引言回覆

謝天謝地,我找到了,參考網址 http://support.microsoft.com/kb/190741/zh-tw
令我吃驚的是,某種程度來說,Vfp比起C#似乎更簡單(當然...像是改密碼,增加使用者等等,我就沒有深入下去)
,程式如下
*-- Code begins here.
PUBLIC oform1
ON ERROR DO errorhnd
oform1=NEWOBJECT("form1")
oform1.Show
RETURN

PROCEDURE errorhnd

DO CASE
CASE ERROR() = 1426
*-- We have an OLE error code.
*-- Insert code to handle it as needed.
OTHERWISE
*-- We have an error not related to ADSI.
*-- Error handling would normally be placed here.
=MESSAGEBOX(STR(ERROR()) +": " + MESSAGE(), 0, "Error")
ENDCASE

ENDPROC

DEFINE CLASS form1 AS form

Height = 253
Width = 457
DoCreate = .T.
AutoCenter = .T.
Caption = "Form1"
Name = "form1"

ADD OBJECT text1 AS textbox WITH ;
Value = "WinNT://MyServer", ;
Height = 23, ;
Left = 12, ;
Top = 206, ;
Width = 238, ;
Name = "Text1"
&& value=你們公司的網域名稱,比如"winNT://Domain.公司名稱.com.tw"
&&再次更正,value應該為你們公司主機的名字,當然上面的作法也可以成立

ADD OBJECT label1 AS label WITH ;
Caption = "ADS Path to Server:", ;
Height = 25, ;
Left = 12, ;
Top = 181, ;
Width = 202, ;
Name = "Label1"

ADD OBJECT cmdfind AS commandbutton WITH ;
Top = 192, ;
Left = 283, ;
Height = 37, ;
Width = 97, ;
Caption = "\<Find", ;
Name = "cmdFind"

ADD OBJECT list1 AS listbox WITH ;
Height = 152, ;
Left = 24, ;
Top = 12, ;
Width = 156, ;
Name = "List1"

ADD OBJECT lblfullname AS label WITH ;
Caption = "", ;
Height = 17, ;
Left = 204, ;
Top = 27, ;
Width = 248, ;
Name = "lblFullName"

ADD OBJECT label2 AS label WITH ;
Caption = "Last Login:", ;
Height = 17, ;
Left = 203, ;
Top = 60, ;
Width = 72, ;
Name = "Label2"

ADD OBJECT lbllastlogin AS label WITH ;
Caption = "", ;
Height = 17, ;
Left = 314, ;
Top = 60, ;
Width = 132, ;
Name = "lblLastLogin"

ADD OBJECT label3 AS label WITH ;
Caption = "Last Logoff:", ;
Height = 17, ;
Left = 203, ;
Top = 83, ;
Width = 73, ;
Name = "Label3"

ADD OBJECT lbllastlogoff AS label WITH ;
Caption = "", ;
Height = 17, ;
Left = 314, ;
Top = 83, ;
Width = 132, ;
Name = "lblLastLogoff"

ADD OBJECT chkdisabled AS checkbox WITH ;
Top = 140, ;
Left = 202, ;
Height = 17, ;
Width = 123, ;
Caption = "Account Disabled", ;
ReadOnly = .T., ;
Name = "chkDisabled"

ADD OBJECT label4 AS label WITH ;
Caption = "Password Expires:", ;
Height = 17, ;
Left = 203, ;
Top = 107, ;
Width = 106, ;
Name = "Label4"

ADD OBJECT lblexpire AS label WITH ;
Caption = "", ;
Height = 17, ;
Left = 314, ;
Top = 107, ;
Width = 68, ;
Name = "lblExpire"

PROCEDURE cmdfind.Click

*-- This could take a while, so update the status bar.
ThisForm.lblFullName.Caption = "Searching..."
ThisForm.List1.Clear

*-- Find the server object.
oADSobj = GETOBJECT(ALLTRIM(ThisForm.Text1.Text))

*-- Populate the list with the users on the server.
*-- We need to filter to get just the users, otherwise
*-- the list will include every object from that server,
*-- such as printers and groups.
FOR EACH Child IN oADSobj
IF Child.Class = "User"
thisform.list1.additem(Child.Name)
ENDIF
ENDFOR
ThisForm.lblFullName.Caption = ""
ENDPROC

PROCEDURE list1.Click

*-- Clear the labels in case we can't get
*-- the values.
ThisForm.lblFullName.Caption = ""
ThisForm.lblLastLogin.Caption = ""
ThisForm.lblLastLogoff.Caption = ""
ThisForm.chkDisabled.Value = 0
ThisForm.lblExpire.Caption = ""

*-- Find the selected item in the list.
FOR nCnt = 1 TO ThisForm.List1.ListCount
IF ThisForm.List1.Selected(nCnt)

*-- Get the user object by building an ADS path
*-- from the server path entered in the text box
*-- and the user name selected from the list.
oUser = GETOBJECT(ALLTRIM(ThisForm.Text1.Text) + ;
"/" + ALLTRIM(ThisForm.List1.Value))

*-- Get the user information and populate the
*-- label controls.
ThisForm.lblFullName.Caption = oUser.FullName
ThisForm.lblLastLogin.Caption = DTOC(oUser.LastLogin)
ThisForm.lblLastLogoff.Caption = DTOC(oUser.LastLogoff)
ThisForm.chkDisabled.Value = oUser.AccountDisabled
ThisForm.lblExpire.Caption = ;
DTOC(oUser.PasswordExpirationDate)
ENDIF
ENDFOR
ENDPROC

PROCEDURE Destroy
ON ERROR
ENDPROC

ENDDEFINE
*-- Code ends here.

_________________
大家好,請多指教


nelsonchuang 在 星期一 四月 14, 2008 2:40 pm 作了第 2 次修改
回頂端
檢視會員個人資料 發送私人訊息
nelsonchuang



註冊時間: 2003-09-04
文章: 563
來自: 臺灣

第 3 樓

發表發表於: 星期一 四月 14, 2008 10:31 am    文章主題: 引言回覆

這是另一個我找到的檔案
來源網址位置:http://support.microsoft.com/kb/192766
這隻程式就真的是算不錯的

你們可以試著輸入Domain.公司名稱.com.tw(網域名稱)
另一個作法是主機名稱,結果會有些不同.

_________________
大家好,請多指教


nelsonchuang 在 星期一 四月 14, 2008 2:42 pm 作了第 1 次修改
回頂端
檢視會員個人資料 發送私人訊息
nelsonchuang



註冊時間: 2003-09-04
文章: 563
來自: 臺灣

第 4 樓

發表發表於: 星期一 四月 14, 2008 10:43 am    文章主題: 引言回覆

這是另一篇比較簡單的說明:
_________________
大家好,請多指教
回頂端
檢視會員個人資料 發送私人訊息
nelsonchuang



註冊時間: 2003-09-04
文章: 563
來自: 臺灣

第 5 樓

發表發表於: 星期一 四月 14, 2008 11:07 am    文章主題: 引言回覆

這是另一篇以ole db連接的方式,但是老實說:
C#,vfp我之前試過,都沒有成功過,應該是我個人功力不足的問題,但是我仍貼上來
http://msdn2.microsoft.com/en-us/library/ms810638.aspx

_________________
大家好,請多指教
回頂端
檢視會員個人資料 發送私人訊息
nelsonchuang



註冊時間: 2003-09-04
文章: 563
來自: 臺灣

第 6 樓

發表發表於: 星期一 四月 14, 2008 11:24 am    文章主題: 引言回覆

這個版是外國人的Vfp討論區,名氣也算不小,我也有登記會員
其中這一篇大家若有有興趣,也可參考比較
http://www.foxite.com/archives/vfp-authentication-on-active-directory-0000137240.htm

_________________
大家好,請多指教
回頂端
檢視會員個人資料 發送私人訊息
nelsonchuang



註冊時間: 2003-09-04
文章: 563
來自: 臺灣

第 7 樓

發表發表於: 星期一 四月 14, 2008 3:11 pm    文章主題: 引言回覆

本來是想試一試用vfp 登入Ad 帳號,無奈用公司用的是vfp 6.0不會出現智能提示
作起來礙手礙腳,家中又沒有Server可以測...
底下這一段又一直出現Moniker cannot open file..
Orz...
底下這一段是從Vb抄來的,作法大至相同,若有高手測試可行,麻煩
把修改後的原始碼丟上來一下,謝謝.
vb代碼

Dim sUser As String = 網域+"\"+使用者名稱
Dim sPassword As String = 密碼
If sUser <> "" Then
Dim oADSI As Object = GetObject("WinNT:")
On Error Resume Next
Dim oIIS As Object = oADSI.OpenDSObject("WinNT://"+網域, sUser, sPassword, 0)

If Err.Number = 0 Then
Response.Write("Logon OK.<BR>") '這是我在Asp.net測試的結果
Else
Response.Write("Logon failed.<BR>")
End If

_________________
大家好,請多指教
回頂端
檢視會員個人資料 發送私人訊息
從之前的文章開始顯示:   
發表新主題   回覆主題    VFP 愛用者社區 首頁 -> VFP 討論區 所有的時間均為 台北時間 (GMT + 8 小時)
1頁(共1頁)

 
前往:  
無法 在這個版面發表文章
無法 在這個版面回覆文章
無法 在這個版面編輯文章
無法 在這個版面刪除文章
無法 在這個版面進行投票
無法 在這個版面附加檔案
無法 在這個版面下載檔案


Powered by phpBB © 2001, 2005 phpBB Group
正體中文語系由 phpbb-tw 維護製作