Salesforce encourages developers to authenticate using OAuth.
However, if you are creating a windows service to get data from SF, you'll need to choose the username/password flow.
https://ap1.salesforce.com/help/doc/en/remoteaccess_oauth_username_password_flow.htm
The Steps include:
1) Add new application via Setup -> Develop -> Remote Access
Under this method, the callback URL will not be used.
2) Perform a POST request
To get the authentication token:
https://login.salesforce.com/services/oauth2/token?grant_type=password&client_id=3MVG9lKcPoNINVBIPJjdw1J9LLM82Hn
FVVX19KY1uA5mu0QqEWhqKpoW3svG3XHrXDiCQjK1mdgAvhCscA9GE&client_secret=1955279925675241571&username=username@salesforceInstance.com&password=SFpassword
3) Parse return JSON and get access_token
{"id":"https://login.salesforce.com/id/00Dx0000000BV7z/005x00000012Q9P",
"issued_at":"1278448832702","instance_url":"https://na1.salesforce.com",
"signature":"0CmxinZir53Yex7nE0TD+zMpvIWYGb/bdJh6XfOH6EQ=","access_token":
"00Dx0000000BV7z!AR8AQAxo9UfVkh8AlV0Gomt9Czx9LjHnSSpwBMmbRcgKFmxOtvxjTrKW1
9ye6PE3Ds1eQz3z8jr3W7_VbWmEu4Q8TVGSTHxs"}
4) Perform a GET request
https://ap1.salesforce.com/services/data/v20.0/sobjects/Account/0019000000B8JxR?fields=AccountNumber,BillingPostalCode
User-Agent: Fiddler
Authorization: OAuth access_token
Host: ap1.salesforce.com
Sunday, March 11, 2012
Monday, February 27, 2012
Salesforce Converting 15digits ID to 18 digits ID via Formula
Sometimes you'll need to convert the 15 digits ID to 18 digits for external programs to compare IDs.
ExistingFifteenDigitsId
& MID("ABCDEFGHIJKLMNOPQRSTUVWXYZ012345",(
IF(FIND(MID(audit_survey__r.audit__r.Id,1,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,1,0)
+IF(FIND(MID(audit_survey__r.audit__r.Id,2,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,2,0)
+IF(FIND(MID(audit_survey__r.audit__r.Id,3,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,4,0)
+IF(FIND(MID(audit_survey__r.audit__r.Id,4,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,8,0)
+IF(FIND(MID(audit_survey__r.audit__r.Id,5,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,16,0)
)+1,1)
& MID("ABCDEFGHIJKLMNOPQRSTUVWXYZ012345",(
IF(FIND(MID(audit_survey__r.audit__r.Id,6,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,1,0)
+IF(FIND(MID(audit_survey__r.audit__r.Id,7,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,2,0)
+IF(FIND(MID(audit_survey__r.audit__r.Id,8,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,4,0)
+IF(FIND(MID(audit_survey__r.audit__r.Id,9,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,8,0)
+IF(FIND(MID(audit_survey__r.audit__r.Id,10,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,16,0)
)+1,1)
& MID("ABCDEFGHIJKLMNOPQRSTUVWXYZ012345",(
IF(FIND(MID(audit_survey__r.audit__r.Id,11,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,1,0)
+IF(FIND(MID(audit_survey__r.audit__r.Id,12,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,2,0)
+IF(FIND(MID(audit_survey__r.audit__r.Id,13,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,4,0)
+IF(FIND(MID(audit_survey__r.audit__r.Id,14,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,8,0)
+IF(FIND(MID(audit_survey__r.audit__r.Id,15,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,16,0)
)+1,1)
ExistingFifteenDigitsId
& MID("ABCDEFGHIJKLMNOPQRSTUVWXYZ012345",(
IF(FIND(MID(audit_survey__r.audit__r.Id,1,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,1,0)
+IF(FIND(MID(audit_survey__r.audit__r.Id,2,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,2,0)
+IF(FIND(MID(audit_survey__r.audit__r.Id,3,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,4,0)
+IF(FIND(MID(audit_survey__r.audit__r.Id,4,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,8,0)
+IF(FIND(MID(audit_survey__r.audit__r.Id,5,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,16,0)
)+1,1)
& MID("ABCDEFGHIJKLMNOPQRSTUVWXYZ012345",(
IF(FIND(MID(audit_survey__r.audit__r.Id,6,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,1,0)
+IF(FIND(MID(audit_survey__r.audit__r.Id,7,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,2,0)
+IF(FIND(MID(audit_survey__r.audit__r.Id,8,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,4,0)
+IF(FIND(MID(audit_survey__r.audit__r.Id,9,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,8,0)
+IF(FIND(MID(audit_survey__r.audit__r.Id,10,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,16,0)
)+1,1)
& MID("ABCDEFGHIJKLMNOPQRSTUVWXYZ012345",(
IF(FIND(MID(audit_survey__r.audit__r.Id,11,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,1,0)
+IF(FIND(MID(audit_survey__r.audit__r.Id,12,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,2,0)
+IF(FIND(MID(audit_survey__r.audit__r.Id,13,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,4,0)
+IF(FIND(MID(audit_survey__r.audit__r.Id,14,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,8,0)
+IF(FIND(MID(audit_survey__r.audit__r.Id,15,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,16,0)
)+1,1)
Tuesday, February 21, 2012
Creating your Own Dropbox Server
Since hard drive space is relatively cheap these days, and if you have a server running 24/7, you can consider the following file sync software to create one/two/n-way sync.
Syncrify - uses "rsync" to copy data. Useful if file versioning is not required(only in paid version and is fairly expensive).
Delta copy - ditto
Allway Sync - free but only support folders available in the file system (no native http/ftp support)
Good Sync - Not free for >100 files, but support file versioning and have native http/ftp support.
Syncrify - uses "rsync" to copy data. Useful if file versioning is not required(only in paid version and is fairly expensive).
Delta copy - ditto
Allway Sync - free but only support folders available in the file system (no native http/ftp support)
Good Sync - Not free for >100 files, but support file versioning and have native http/ftp support.
Tuesday, February 14, 2012
Assembla SVN
If you are familiar with SVN, you can have 1GB of repository space on Assembla with unlimited users for FREE. This is perfect for most homebrew projects.
Tuesday, January 3, 2012
Remote Desktop to Your Home Computer Behind a Corporate Firewall
Most corporate firewalls will ban websites such as logmein. However, they usually won't ban your home URL or your static internet IP address provided by your ISP.
Scenario 1 - Basic Firewall with Non-Restricted Access over HTTPS
For smaller enterprises, they might allow unrestricted outbound access over port 443. If this is the case, setup your home router to accept port 443(HTTPS) and redirect that to your local PC on port 3389(RDP).
Scenario 2 - Via Citrix XenDesktop
Citrix's XenDesktop Express is free and allow up to four concurrent users to connect to four remote desktop. It will require seperate servers though, ie
-Desktop Delivery Controller (DDC)
-Provisioning Server for Desktop
Scenario 3 - Terminal Services Gateway
Microsoft 2008 Server can act as a TS gateway and allow external clients to connect to the TS gateway and talk to computers behind the gateway.
Scenario 1 - Basic Firewall with Non-Restricted Access over HTTPS
For smaller enterprises, they might allow unrestricted outbound access over port 443. If this is the case, setup your home router to accept port 443(HTTPS) and redirect that to your local PC on port 3389(RDP).
Scenario 2 - Via Citrix XenDesktop
Citrix's XenDesktop Express is free and allow up to four concurrent users to connect to four remote desktop. It will require seperate servers though, ie
-Desktop Delivery Controller (DDC)
-Provisioning Server for Desktop
Scenario 3 - Terminal Services Gateway
Microsoft 2008 Server can act as a TS gateway and allow external clients to connect to the TS gateway and talk to computers behind the gateway.
Wednesday, November 23, 2011
Runas Different Credentials In Command Prompt
Sometimes you need to run an executable as a different user via command prompt:
- in scripts
- in Windows 2008 (not 2008 R2), you cannot use shift right click to "run as different user"
Windows come with a command line tool called "runas", which allow users to execute anything as a different user, in the following syntax
runas /user domain\username "full path to exe"
ie.
runas /user domain\username "c:\temp\temp.exe /a /l /r"
- in scripts
- in Windows 2008 (not 2008 R2), you cannot use shift right click to "run as different user"
Windows come with a command line tool called "runas", which allow users to execute anything as a different user, in the following syntax
runas /user domain\username "full path to exe"
ie.
runas /user domain\username "c:\temp\temp.exe /a /l /r"
Tuesday, November 15, 2011
Active Directory MMCs and Command Line Tools
Administration Tools on your Windows XP/7:
If you need to manage/export data from AD outside of your windows server, install:
- the "Windows Server 2003 Administration Tools Pack" (for windows 2003 AD servers)
http://www.microsoft.com/download/en/details.aspx?id=16770
OR
- the "Remote Server Administration Tools for Windows 7" (for windows 2008 AD servers)
http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=7887
They provide Active Directory related MMCs and Directory Services command line tools.
Quickly Exporting AD Information
Dsquery.exe allows you to find any users/groups/OUs/computers etc based on their name/attributes
http://technet.microsoft.com/en-us/library/cc732952(WS.10).aspx
Examples:
To retrieve all AD Groups with the prefix "foo"
dsquery group -name foo*
To retrieve all the users in the container "Users", domain "microsoft.com"
dsquery user cn=users,dc=microsoft,dc=com
Other AD Command Line Tools
Microsoft has also allowed you to perform most basic AD operations such as adding users/groups, resetting passwords, deleting accounts/groups via the command-line tools
http://support.microsoft.com/kb/322684
If you need to manage/export data from AD outside of your windows server, install:
- the "Windows Server 2003 Administration Tools Pack" (for windows 2003 AD servers)
http://www.microsoft.com/download/en/details.aspx?id=16770
OR
- the "Remote Server Administration Tools for Windows 7" (for windows 2008 AD servers)
http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=7887
They provide Active Directory related MMCs and Directory Services command line tools.
Quickly Exporting AD Information
Dsquery.exe allows you to find any users/groups/OUs/computers etc based on their name/attributes
http://technet.microsoft.com/en-us/library/cc732952(WS.10).aspx
Examples:
To retrieve all AD Groups with the prefix "foo"
dsquery group -name foo*
To retrieve all the users in the container "Users", domain "microsoft.com"
dsquery user cn=users,dc=microsoft,dc=com
Other AD Command Line Tools
Microsoft has also allowed you to perform most basic AD operations such as adding users/groups, resetting passwords, deleting accounts/groups via the command-line tools
http://support.microsoft.com/kb/322684
Subscribe to:
Posts (Atom)