帳號整合開發工具-IDI

最近在研究IBM的Tivoli Directory Integrator (有看到的簡稱為ITDI、TDI或IDI,以下稱IDI),我只能說這個軟體的概念真的很不錯,所以才值得我介紹,但我覺得還有一些問題是實際開發及上線用時才會發現的問題。

另外,其實我研究的主軸是 Tivoli Identity Manager (用來做帳號整合管理的系統),IDI只是它的輔助工具,不過TIM很多功能其實是依賴IDI才能存在,所以先從IDI講起。

姑且暫時不把缺點拿上來談,我試著把我所知道的寫出來看看為什麼我說它是概念不錯的軟體。

老話一句,我不是IBM的員工,所以有些東西不太清楚。

IDI是啥

我引述來自IBM案例網站中的一句話

IBM Directory Integrator(IDI)就是一個基於100% Java技術的目錄元件系統,不但可以跨平台執行,而且其Assembly Line工作模式可以在不匯入一個集中用戶存儲的資料庫的情況下就實現分散式的用戶訊息同步和複雜操作。

可能看完這段話沒什麼感覺,簡單的說IDI可以提供一個開發與運作的工具,讓多個不同平台的使用者資料庫同步或是轉換一個介面讓另一個系統控制。

也就是說,今天無論我原本的系統是用哪家的系統開發,只要是IDI可以連接的對象(relational databases, mail systems, file formats, message queues, web services and a host of other data sources),IDI都要讓你可以與它整合。

圖片引用自Developing a custom TIM agent with TDI

關鍵技術

那麼IDI到底做了什麼事簡化我們的工作呢?

  • 對於現有帳號資料來源:提供各式各樣的連接器(Connector) ,方便存取資料,且設定完的連接器還可再被當父連接器繼承設定,不用寫一堆程式連線唷
    置中
  • 提供了幾種方式讓其他系統能整合:使得我的系統在存取資料來源時,有個固定的介面,而且瑣碎的工作也可交由IDI達成
  • 透過簡單的介面編輯處理流程(Assembly Line):針對取得的資料做名稱的對應與進一步呼叫其他連接器處理
  • 也可以用Javascript撰寫程式,進行資料處理或呼叫其他流程(Assembly Line)

總結

IDI是個中介處理程序的開發工具,不過我不是來賣產品的,只是跟大家說有這樣的東西,概念不錯。

開頭我就有講到但書,這個工具既然屬於開發工具,它的介面也算OK,不過缺點也不少,像是以JavaScript做為程式語言的部份,就充分展現了Javascript沒有編輯時的輔助,一切都要靠經驗與資料才知道怎麼寫才對,偵錯、除錯也很困難。

再者,雖然安裝後有許多小範例,可惜這些範例的解釋資訊不足,基本上要了解不是很簡單,而且我還有遇到範例是有問題的(像是WebService的部份),感覺像是拿前幾個版本的IDI開發範例直接放到新的IDI,不知是不是我自己搞錯了~

另外還有效能與資料來源過大等問題~

與TIM這個主產品整合時,開發要注意的事就更多了~這真是IBM產品的特色呀

相關連結

Tweak UI:讓2003與XP都可自動登入

我之前曾在MS-DOS commands與磁碟定期重組這篇中談到XP懶人開機法,就是能在XP開機時,不用輸入帳號密碼,就能自動登入的方法。

我最近發現連Windows 2003都可以設定自動登入,而最簡單的設定方法就是使用MS自家提供的小工具:Tweak UI

軟體

Tweak UI

  • Version 2.10
  • Windows XP or Windows Server 2003.

方法

  • 首先,到Microsoft PowerToys for Windows XP下載Tweak UI(安裝檔連結)
  • 安裝後,選開始→執行→輸入【Tweakui】
  • 然後會出現如下視窗
  • 選擇Logon→AutoLogon→勾選【Log on automatically at system startup】,並輸入要登入的帳號,點選【Set Password】輸入登入的密碼

  • 點選【Apply】套用設定,這樣就完成了

結論

自動登入是很方便,不過基於安全性考量,如果你的電腦怕被別人碰還是乖乖輸入密碼會比較好~

這個工具XP或2003都可適用,當然XP直接用MS-DOS commands與磁碟定期重組這篇中談到XP懶人開機法就可了。

此外,這個工具也提供了一些原本隱藏的設定讓我們能控制Windows的效果,有興建的人可玩玩看。

相關連結

大掃除~用批次檔清理電腦

過年大掃除,你有幫你的電腦大掃除了嗎~

我前陣子幫家裡兩台NB重新安裝一次Windows,還做了系統備份,希望新年的開始能跑的穩定點~但還有4台電腦等著我維護...工作這麼忙,重安裝又要重設定~哪那麼多閒功夫呀~

那麼至少清除一下電腦中暫存的垃圾吧~懂電腦的人就會知道電腦中的垃圾要去哪清~

不過一個一個手動清除會不會太慢了點~這時弄個批次檔就解決啦~

作法

打開記事本,填入以下命令,然後存檔時命名為【cleanSystem.bat】

@echo off
echo 正在清除系統垃圾檔案中,請稍候......
del /f /s /q %systemdrive%\*.tmp
del /f /s /q %systemdrive%\*._mp
del /f /s /q %windir%\*.log
del /f /s /q %systemdrive%\*.gid
del /f /s /q %systemdrive%\*.chk
del /f /s /q %systemdrive%\*.old
del /f /s /q %systemdrive%\*.bak
del /f /s /q %systemdrive%\recycled\*.*
del /f /s /q %windir%\*.bak
del /f /s /q %windir%\prefetch\*.*
rd /s /q %windir%\temp & md %windir%\temp
del /f /q %userprofile%\cookies\*.*
del /f /q %userprofile%\recent\*.*
del /f /s /q "%userprofile%\Local Settings\Temporary Internet Files\*.*"
del /f /s /q "%windir\Temporary Internet Files\*.*"
del /f /s /q "%userprofile%\Local Settings\Temp\*.*"
del /f /s /q "%userprofile%\recent\*.*"
del /f /s /q "%temp%\*.*"
echo 清除系統垃圾檔案完成!!
echo. & pause

再來點兩下這個檔讓它執行就好啦~

原理

簡單來說,這個批次檔執行後,會將你系統根目錄(如C:\)下的一些暫存檔、備份檔改刪除~

然後刪除系統目錄(如C:\WINDOWS)下的備份檔~

再來就是暫存區的檔案與瀏覽器的暫存區~

完成後基本上大多數的垃圾就消失了~

覺得不夠乾淨?

那麼建議你做一些標準清除的動作

  • 開始→程式集→附屬應用程式→系統工具→清理磁碟 (對應指令: cleanmgr)
  • 清除瀏覽器暫存檔案與 Cookie (Internet Explorer 5.5/6.0 適用):
    • 結束 Internet Explorer,然後結束「Windows 檔案總管」的所有執行個體。
    • 按一下 [開始],再按一下 [控制台],然後按兩下 [網際網路選項]。
    • 按一下 [一般] 索引標籤,然後按一下 [Temporary Internet files] 下方的 [刪除檔案]。
    • 在 [刪除檔案] 對話方塊中,按一下以選取 [刪除所有離線內容] 核取方塊,然後按一下 [確定]。
    • 按一下 [確定]。
  • 清除瀏覽器暫存檔案與 Cookie (Mozilla Firefox 適用):
    • 啟動 Mozilla Firefox
    • 點選「Tools」→「Options」
    • 點選「Privacy」
    • 點選「Clear All」
  • 掃瞄、修復、重組磁碟
  • 其他動作(我沒玩過,歡迎有用過的談談心得)
    • 清除不用的右鍵選單與註冊表內容
    • 找清除軟體來幫你清

相關連結

管理Windows遠端桌面工具-MMC

相信有很多人都已經會使用Windows提供的遠端桌面了吧(如果還不會請參考 Windows初始安裝設定或是在 Windows XP 中安裝遠端桌面網路連線)

不過如果你常常要連到很多台不一樣的電腦,甚至在這些電腦游移,或許你會像我一樣,覺得切換起來有些麻煩吧~

最近我發現其實微軟有提供了一個工具,是MMC(Microsoft Management Console),底下有一個嵌入的元件叫tsmmc,基本上就能夠解決切換還有管理的問題囉

在哪

這個系統管理工具其實是在Windows 2003的光碟中有附安裝程式,但因為大多數的一般使用者都用XP,所以一直沒注意到~

在這裡告訴大家兩個取得的方式

安裝完後就可以使用了

怎麼用

你可以選【開始】→【執行】,輸入【tsmmc.msc】(或是執行【%systemroot%\system32\tsmmc.msc】),就可以看到以下視窗

然後就可以加入你想遠端連線的電腦資訊

連線

然後就可是看到結果了(預設會把解析度調成視窗大小,當然這都是可設定的)

依此方式可以加很多台遠端連線~

設定完後,你可以把這個連線的清單另存在桌面,下次就開那個設定檔就好了~

結論

有了這樣的工具,連很多電腦~要切來切去~都隨你切啦~

還有一點,就是Windows 2003 server原本如果用一般的遠端連線,它會另外開啟一個相同使用者名稱的使用者,也就會跑出好多個終端機連線~

但用了這個管理工具,它就變的跟XP的遠端連線一樣,會登出電腦前的使用者,讓你控制~這點倒解開了我多年的疑惑~

針對XP預設的遠端桌面程式,精由網友提供的資訊(感謝Gary),如果想要如同連XP般連到2003的桌面,而不是使用終端機的方式連線,只要改在呼叫程式前加上/console 的參數就行了

具體方法有兩個

  • 開始→執行→【mstsc /console】
  • 將開始→程式集→附屬應用程式→通訊→【遠端桌面連線】的捷徑複製一份放桌面,然後修改目標到【%SystemRoot%\system32\mstsc.exe /console】就可以用它開啟了

當然tsmmc中也可以取消掉預設的【連線到主控台】,這樣在連線時就會以終端機的方式連線了。

不過經過我測試,有的電腦用這樣的遠端好像連線會有問題,應該是作業系統的版本差異問題,大多數都OK的啦~

相關連結

用VB.Net寫的RSS Feed產生函式

我自己是很喜歡用RSS的服務的人,所以寫網站或是做一些事時常會想到要弄個RSS Feed,最起碼自己會用的到~

不過VB中並沒有直接提供RSS Feed的產生函式,國外有些網站好像有提供類似的東西,不過不是要註冊就是有些複雜,所以我就自己寫了一個~

作法

我原本是用FileIO那篇的寫文字檔的方式,用比較笨的方法產生RSS Feed~

不過後來我改用以下的內容,將RSS的內容,以Xml.XmlDocument這個類別來產生XML的結構,順便學習在VB.Net下怎麼自己產生XML結構,並且它會自己將HTML編碼的問題解決

RSS 2.0的規格則是參考RSS 2.0 Specification中的規定,來設計RSS feed的元素,不過我剔除掉了一些我覺得沒用或是我看不出來功能的標籤,來產生結果

模組程式碼

Imports System
Module RSSGenModule
   ''' 
   ''' RSSGenerator V1.0 is builded by Allen
   ''' Please get the newest information at
   ''' http://allen080.blogspot.com/
   ''' 
   Public Class RSSGenerator
       Public Sub createRSS(ByRef rssfeed As RSSFeed, ByVal path As String)
           'RSS 2.0 specification is Reference at
           'http://www.rssboard.org/rss-specification/
           Dim x As New Xml.XmlDocument
           x.LoadXml("" + "" + "")

           Dim channel As Xml.XmlElement = x.CreateElement("channel")
           x.DocumentElement.AppendChild(channel)

           Dim element As Xml.XmlElement
           Dim subElement As Xml.XmlElement
           'set channel start
           element = x.CreateElement("title")
           channel.AppendChild(element)
           element.InnerText = rssfeed.title
           If Not rssfeed.link Is Nothing Then
               element = x.CreateElement("link")
               channel.AppendChild(element)
               element.InnerText = rssfeed.link
           End If
           If Not rssfeed.description Is Nothing Then
               element = x.CreateElement("description")
               channel.AppendChild(element)
               element.InnerText = rssfeed.description
           End If
           If Not rssfeed.language Is Nothing Then
               element = x.CreateElement("language")
               channel.AppendChild(element)
               element.InnerText = rssfeed.language
           End If
           If Not rssfeed.copyright Is Nothing Then
               element = x.CreateElement("copyright")
               channel.AppendChild(element)
               element.InnerText = rssfeed.copyright
           End If
           If Not rssfeed.managingEditor Is Nothing Then
               element = x.CreateElement("managingEditor")
               channel.AppendChild(element)
               element.InnerText = rssfeed.managingEditor
           End If

           If Not rssfeed.webMaster Is Nothing Then
               element = x.CreateElement("webMaster")
               channel.AppendChild(element)
               element.InnerText = rssfeed.webMaster
           End If

           element = x.CreateElement("pubDate")
           channel.AppendChild(element)
           element.InnerText = (rssfeed.pubDate.AddHours(-8)).ToString("r")

           element = x.CreateElement("lastBuildDate")
           channel.AppendChild(element)
           element.InnerText = (rssfeed.lastBuildDate.AddHours(-8)).ToString("r")

           If Not rssfeed.category Is Nothing Then
               element = x.CreateElement("category")
               channel.AppendChild(element)
               element.InnerText = rssfeed.category
           End If
           If Not rssfeed.generator Is Nothing Then
               element = x.CreateElement("generator")
               channel.AppendChild(element)
               element.InnerText = rssfeed.generator
           End If
           If Not rssfeed.docs Is Nothing Then
               element = x.CreateElement("docs")
               channel.AppendChild(element)
               element.InnerText = rssfeed.docs
           End If


           If Not rssfeed.image Is Nothing Then
               element = x.CreateElement("image")
               channel.AppendChild(element)
               'set image start
               If Not rssfeed.image.title Is Nothing Then
                   subElement = x.CreateElement("title")
                   element.AppendChild(subElement)
                   subElement.InnerText = rssfeed.image.title
               End If
               If Not rssfeed.image.link Is Nothing Then
                   subElement = x.CreateElement("link")
                   element.AppendChild(subElement)
                   subElement.InnerText = rssfeed.image.link
               End If
               subElement = x.CreateElement("url")
               element.AppendChild(subElement)
               subElement.InnerText = rssfeed.image.url
               If Not rssfeed.image.description Is Nothing Then
                   subElement = x.CreateElement("description")
                   element.AppendChild(subElement)
                   subElement.InnerText = rssfeed.image.description
               End If
               'set image end
           End If
           If Not rssfeed.itmes Is Nothing Then
               For Each item As RSSElement In rssfeed.itmes
                   element = x.CreateElement("item")
                   channel.AppendChild(element)
                   'set item start
                   subElement = x.CreateElement("title")
                   element.AppendChild(subElement)
                   subElement.InnerText = item.title
                   If Not item.link Is Nothing Then
                       subElement = x.CreateElement("link")
                       element.AppendChild(subElement)
                       subElement.InnerText = item.link
                   End If
                   If Not item.description Is Nothing Then
                       subElement = x.CreateElement("description")
                       element.AppendChild(subElement)
                       subElement.InnerText = item.description
                   End If
                   If Not item.author Is Nothing Then
                       subElement = x.CreateElement("author")
                       element.AppendChild(subElement)
                       subElement.InnerText = item.author
                   End If
                   If Not item.category Is Nothing Then
                       subElement = x.CreateElement("category")
                       element.AppendChild(subElement)
                       subElement.InnerText = item.category
                   End If
                   If Not item.comments Is Nothing Then
                       subElement = x.CreateElement("comments")
                       element.AppendChild(subElement)
                       subElement.InnerText = item.comments
                   End If
                   If Not item.guid Is Nothing Then
                       subElement = x.CreateElement("guid")
                       subElement.SetAttribute("isPermaLink", "false")
                       element.AppendChild(subElement)
                       subElement.InnerText = item.guid
                   End If

                   subElement = x.CreateElement("pubDate")
                   element.AppendChild(subElement)
                   subElement.InnerText = (item.pubDate.AddHours(-8)).ToString("r")
                   'set item end
               Next
           End If
           'set channel end

           'write to file
           Dim settings As New Xml.XmlWriterSettings()
           settings.Indent = True
           settings.IndentChars = "    "
           settings.Encoding = System.Text.Encoding.UTF8
           Using writer As Xml.XmlWriter = Xml.XmlWriter.Create(path, settings)
               x.WriteTo(writer)
               writer.Flush()
           End Using
       End Sub
   End Class

   Public Class RSSElement
       Private _title As String
       Private _link As String
       Private _description As String
       Private _author As String
       Private _category As String
       Private _comments As String
       Private _guid As String
       Private _pubDate As Date
       Public Property pubDate() As Date
           Get
               Return _pubDate
           End Get
           Set(ByVal value As Date)
               _pubDate = value
           End Set
       End Property

       Public Property guid() As String
           Get
               Return _guid
           End Get
           Set(ByVal value As String)
               _guid = value
           End Set
       End Property

       ''' 
       ''' 回應的URL
       ''' 
       Public Property comments() As String
           Get
               Return _comments
           End Get
           Set(ByVal value As String)
               _comments = value
           End Set
       End Property
       Public Property category() As String
           Get
               Return _category
           End Get
           Set(ByVal value As String)
               _category = value
           End Set
       End Property

       ''' 
       ''' E-Mail
       ''' 
       Public Property author() As String
           Get
               Return _author
           End Get
           Set(ByVal value As String)
               _author = value
           End Set
       End Property

       Public Property description() As String
           Get
               Return _description
           End Get
           Set(ByVal value As String)
               _description = value
           End Set
       End Property

       Public Property title() As String
           Get
               Return _title
           End Get
           Set(ByVal value As String)
               _title = value
           End Set
       End Property
       Public Property link() As String
           Get
               Return _link
           End Get
           Set(ByVal value As String)
               _link = value
           End Set
       End Property
   End Class

   Public Class RSSImage
       Private _title As String
       Private _link As String
       Private _url As String
       Private _description As String
       Public Property description() As String
           Get
               Return _description
           End Get
           Set(ByVal value As String)
               _description = value
           End Set
       End Property

       Public Property url() As String
           Get
               Return _url
           End Get
           Set(ByVal value As String)
               _url = value
           End Set
       End Property

       Public Property link() As String
           Get
               Return _link
           End Get
           Set(ByVal value As String)
               _link = value
           End Set
       End Property

       Public Property title() As String
           Get
               Return _title
           End Get
           Set(ByVal value As String)
               _title = value
           End Set
       End Property
   End Class

   Public Class RSSFeed
       Private _title As String
       Private _link As String
       Private _description As String
       Private _language As String = "zh-tw"
       Private _copyright As String
       Private _managingEditor As String
       Private _webMaster As String
       Private _guid As String
       Private _pubDate As Date = Now
       Private _lastBuildDate As Date = Now
       Private _category As String
       Private _generator As String
       Private _docs As String = "http://www.rssboard.org/rss-specification"
       Private _image As RSSImage
       Private _items As ArrayList

       ''' 
       ''' 元素型態是RSSElement
       ''' 
       Public Property itmes() As ArrayList
           Get
               Return _items
           End Get
           Set(ByVal value As ArrayList)
               _items = value
           End Set
       End Property
       Public Property image() As RSSImage
           Get
               Return _image
           End Get
           Set(ByVal value As RSSImage)
               _image = value
           End Set
       End Property

       ''' 
       ''' URL
       ''' 
       Public Property docs() As String
           Get
               Return _docs
           End Get
           Set(ByVal value As String)
               _docs = value
           End Set
       End Property

       Public Property generator() As String
           Get
               Return _generator
           End Get
           Set(ByVal value As String)
               _generator = value
           End Set
       End Property

       Public Property category() As String
           Get
               Return _category
           End Get
           Set(ByVal value As String)
               _category = value
           End Set
       End Property

       Public Property lastBuildDate() As Date
           Get
               Return _lastBuildDate
           End Get
           Set(ByVal value As Date)
               _lastBuildDate = value
           End Set
       End Property
       Public Property pubDate() As Date
           Get
               Return _pubDate
           End Get
           Set(ByVal value As Date)
               _pubDate = value
           End Set
       End Property

       Public Property guid() As String
           Get
               Return _guid
           End Get
           Set(ByVal value As String)
               _guid = value
           End Set
       End Property

       ''' 
       ''' E-Mail
       ''' 
       Public Property managingEditor() As String
           Get
               Return _managingEditor
           End Get
           Set(ByVal value As String)
               _managingEditor = value
           End Set
       End Property

       ''' 
       ''' E-Mail
       ''' 
       Public Property webMaster() As String
           Get
               Return _webMaster
           End Get
           Set(ByVal value As String)
               _webMaster = value
           End Set
       End Property

       Public Property copyright() As String
           Get
               Return _copyright
           End Get
           Set(ByVal value As String)
               _copyright = value
           End Set
       End Property

       Public Property language() As String
           Get
               Return _language
           End Get
           Set(ByVal value As String)
               _language = value
           End Set
       End Property

       Public Property description() As String
           Get
               Return _description
           End Get
           Set(ByVal value As String)
               _description = value
           End Set
       End Property

       Public Property title() As String
           Get
               Return _title
           End Get
           Set(ByVal value As String)
               _title = value
           End Set
       End Property
       Public Property link() As String
           Get
               Return _link
           End Get
           Set(ByVal value As String)
               _link = value
           End Set
       End Property
   End Class

End Module

使用方法

這個模組中主要有4個類別,分別是

  • RSSFeed:整個RSS的資料都存在這裡面,如果沒有被設定到的屬性,就不會被寫入檔案中(日期除外)
  • RSSImage:用來顯示Logo的資訊,如果沒有Logo就不要把它設定給RSSFeed就好了
  • RSSElement:用來存每一筆新資訊的地方,在RSSFeed中是被ArrayList存起來的
  • RSSGenerator:將路徑與RSSFeed交給其中的createRSS函式,就能產生一個RSS feed檔

使用範例

            Dim rssfeed As New RSSFeed
           rssfeed.title = title
           rssfeed.link = url
           rssfeed.description = title
           rssfeed.generator = "倫倫3號"
           rssfeed.webMaster = "allen080+Tech@gmail.com"
           Dim rssimage As New RSSImage
           rssfeed.image = rssimage
           rssimage.title = title
           rssimage.link = url
           rssimage.url = url + "images/fslogo.jpg"
           rssfeed.itmes = New ArrayList
           Dim notes As ArrayList = gbdatas
           For Each item As GuestBookData In notes
               Dim rsselement As New RSSElement
               rsselement.title = item.title
               rsselement.author = item.eMail + " (" + item.name + ")"
               rsselement.link = item.url
               rsselement.description = item.content
               rsselement.pubDate = item.time
               rsselement.guid = item.url
               rssfeed.itmes.Add(rsselement)
           Next

           Dim rssgen As New RSSGenerator
           rssgen.createRSS(rssfeed, path)

總結

有這樣的一個類別就可以很快的產生出屬於自己的RSS Feed,當然這個xml檔要放在網頁伺服器上,我通常是用IIS就解決了~

完成的檔案可以透過Feed Validator for Atom and RSS這樣的網站來做驗證,不過如果只是一些小警告、小錯誤不理他也沒關係,只要你的RSS Reader不會讀不出來就好了

寫完這個RSS產生函式,如果有空我會找時間看看Atom的不同,如果有必要,也會寫Atom的版本~

參考連結

這裡是關於技術的手札~

也歡迎大家到

倫與貓的足跡



到噗浪來

關心一下我唷!
by 倫
 
Copyright 2009 倫倫3號Beta-Log All rights reserved.
Blogger Templates created by Deluxe Templates
Wordpress Theme by EZwpthemes