{"id":99,"date":"2008-11-12T15:47:00","date_gmt":"2008-11-12T20:47:00","guid":{"rendered":"http:\/\/www.dev-notes.com\/blog\/2008\/11\/12\/building-an-aim-buddy-list-from-your-database-employee-table-with-vbscript\/"},"modified":"2008-11-12T15:47:00","modified_gmt":"2008-11-12T20:47:00","slug":"building-an-aim-buddy-list-from-your-database-employee-table-with-vbscript","status":"publish","type":"post","link":"https:\/\/www.dev-notes.com\/blog\/2008\/11\/12\/building-an-aim-buddy-list-from-your-database-employee-table-with-vbscript\/","title":{"rendered":"Building an AIM buddy list from your database employee table with VBScript"},"content":{"rendered":"<p>The code below can be used against Oracle, SQL Server, or MySQL database table to automatically create an AIM buddy list.  The SQL statement should select out a &#8220;group_name&#8221; field (ideas: a department name such as &#8220;Accounting&#8221; or &#8220;Purchasing&#8221;, an office location such as &#8220;Taipei&#8221; or &#8220;New York&#8221;, etc.) and an &#8220;aim_name&#8221; field.  The &#8220;group_name&#8221; will be used as AIM groups, while &#8220;aim_name&#8221; are the users&#8217; actual registered AIM names.  The output file is a flat text file in a format that can be imported into AIM.<\/p>\n<pre class=\"code\">\n'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''\n' AIM Buddy List Builder                                        '\n'                                                               '\n' Description: Builds an AIM buddy list from your database      '\n'      employee table.                                          '\n' Author: C. Peter Chen                                         '\n' Version Tracker:                                              '\n'       1.0   20081021   Base version                           '\n'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''\noption explicit\ndim dbType, dbHost, dbName, dbUser, dbPass, outputFile, sqlstr\n\n'''''''''''''''''\n' Configuration '\n'''''''''''''''''\ndbType = \"oracle\"                ' Valid values: \"oracle\", \"sqlserver\", \"mysql\"\ndbHost = \"hostName\"              ' Hostname of the database server\ndbName = \"dbName\"                ' Name of the database\/SID\ndbUser = \"user\"                  ' Name of the user\ndbPass = \"password\"              ' Password of the above-named user\noutputFile = \"c:buddylist.blt\"  ' Path and file name of the output CSV file\n\n' SQL statement below; be sure to select out \"group_name\" and \"aim_name\" in your SQL statement.\nsqlStr = \"select department_name as group_name, aim_name from employees_table where aim_name is not null order by department_name, aim_name\"\n'''''''''''''''''''''\n' End Configuration '\n'''''''''''''''''''''\n\ndim fso, conn\n\n'Create filesystem object \nset fso = CreateObject(\"Scripting.FileSystemObject\")\n\n'Database connection info\nset Conn = CreateObject(\"ADODB.connection\")\nConn.ConnectionTimeout = 30\nConn.CommandTimeout = 30\nif dbType = \"oracle\" then\n\tconn.open(\"Provider=MSDAORA.1;User ID=\" & dbUser & \";Password=\" & dbPass & \";Data Source=\" & dbName & \";Persist Security Info=False\")\nelseif dbType = \"sqlserver\" then\n\tconn.open(\"Driver={SQL Server};Server=\" & dbHost & \";Database=\" & dbName & \";Uid=\" & dbUser & \";Pwd=\" & dbPass & \";\")\nelseif dbType = \"mysql\" then\n\tconn.open(\"DRIVER={MySQL ODBC 3.51 Driver}; SERVER=\" & dbHost & \";PORT=3306;DATABASE=\" & dbName & \"; UID=\" & dbUser & \"; PASSWORD=\" & dbPass & \"; OPTION=3\")\nend if\n\ndim a, showList, prevGroup\n\nset a = fso.createtextfile(outputFile)\na.writeline (\"Config {\")\na.writeline (\" version 1\")\na.writeline (\"}\")\na.writeline (\"User {\")\na.writeline (\" screenName dummyAimName\")\na.writeline (\"}\")\na.writeline (\"Buddy {\")\na.writeline (\" list {\")\n\nset showList = conn.execute(sqlstr)\n\nprevGroup = \"placeholder\"\ndo while not showList.eof\n\tif (showList(\"group_name\") <> prevGroup) then\n\t\tif (prevGroup <> \"placeholder\") then\n\t\t\ta.writeline (\"  }\")\n\t\tend if\n\t\ta.writeline (\"  \"\"\" + showList(\"group_name\") + \"\"\" {\")\n\tend if\n\ta.writeline (\"   \" + showList(\"aim_name\"))\n\tprevGroup = showList(\"group_name\")\n\tshowList.movenext\nloop\nshowList.close\nset showList = nothing\n\na.writeline (\"  }\")\n\na.writeline (\" }\")\na.writeline (\"}\")\n\n' Close\nset a = nothing\nset fso = nothing\nconn.close\nset conn = nothing\n\n'You're all done!!  Enjoy the file created.\nmsgbox(\"AIM Buddy List Created!\")\n<\/pre>\n<p>Interested in obtaining a generic AIM buddy list import file format?  Please see below for an illustration with fictional data.<\/p>\n<pre class=\"code\">\nConfig {\n version 1\n}\nUser {\n screenName dummyAimName\n}\nBuddy {\n list {\n  \"Accounting\" {\n   MrCFO_fictionalUser\n   BobAtAccounting_fictionalUser\n   JaneDoe_fictionalUser\n  }\n  \"Purchasing\" {\n   LewisTheBuyer_fictionalUser\n  }\n  \"Useless Employees\" {\n   PaulJohnson_fictionalUser\n  }\n }\n}\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This article is a sample of how you can use a SQL statement against a database table to generate an AOL Instant Messenger buddy list.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21,20,39,11],"tags":[],"class_list":["post-99","post","type-post","status-publish","format-standard","hentry","category-mysql","category-oracle","category-sql-server","category-vbscript"],"_links":{"self":[{"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/posts\/99","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/comments?post=99"}],"version-history":[{"count":0,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/posts\/99\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/media?parent=99"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/categories?post=99"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/tags?post=99"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}