Retrieve email and phone number via Google API - coldfusion

I am working with Google API using Coldfusion, So making a call to the following URL:
https://www.googleapis.com/plus/v1/people/{userID}?key={MyGoogleKey}
I am able to get the details of the user. Whatever they have shared in their google plus account. One thing that is missing is their email address and phone numbers (if available).
I think, I need to make another call to the API to get the email and phone numbers, but I am struggling with how to do that. Here is the code I am trying to use:
<cfset objGoogPlus = createObject("component","services.auth").init(apikey="#application.google_server_key#",parseResults=true)>
<cfdump var="#objGoogPlus.people_get(userID='#data.id#')#">
<cffunction name="init" access="public" output="false" hint="I am the constructor method.">
<cfargument name="apiKey" required="true" type="string" hint="I am the application's API key to access the services." />
<cfargument name="parseResults" required="false" type="boolean" default="false" hint="A boolean value to determine if the output data is parsed or returned as a string" />
<cfset variables.instance.apikey = arguments.apiKey />
<cfset variables.instance.parseResults = arguments.parseResults />
<cfset variables.instance.endpoint = 'https://www.googleapis.com/plus/v1/' />
<cfreturn this />
</cffunction>
<cffunction name="getparseResults" access="package" output="false" hint="I return the parseresults boolean value.">
<cfreturn variables.instance.parseResults />
</cffunction>
<cffunction name="people_get" access="public" output="false" hint="I get a person's profile.">
<cfargument name="userID" required="true" type="string" hint="The ID of the person to get the profile for. The special value 'me' can be used to indicate the authenticated user." />
<cfargument name="parseResults" required="false" type="boolean" default="#getparseResults()#" hint="A boolean value to determine if the output data is parsed or returned as a string" />
<cfset var strRequest = variables.instance.endpoint & 'people/' & arguments.userID & '?key=' & variables.instance.apikey />
<cfreturn getRequest(URLResource=strRequest, parseResults=arguments.parseResults) />
</cffunction>
<cffunction name="getRequest" access="private" output="false" hint="I make the GET request to the API.">
<cfargument name="URLResource" required="true" type="string" hint="I am the URL to which the request is made." />
<cfargument name="parseResults" required="true" type="boolean" hint="A boolean value to determine if the output data is parsed or returned as a string" />
<cfset var cfhttp = '' />
<cfhttp url="#arguments.URLResource#" method="get" />
<cfreturn handleReturnFormat(data=cfhttp.FileContent, parseResults=arguments.parseResults) />
</cffunction>
<cffunction name="handleReturnFormat" access="private" output="false" hint="I handle how the data is returned based upon the provided format">
<cfargument name="data" required="true" type="string" hint="The data returned from the API." />
<cfargument name="parseResults" required="true" type="boolean" hint="A boolean value to determine if the output data is parsed or returned as a string" />
<cfif arguments.parseResults>
<cfreturn DeserializeJSON(arguments.data) />
<cfelse>
<cfreturn serializeJSON(DeserializeJSON(arguments.data)) />
</cfif>
</cffunction>
<cffunction access="public" name="getProfileEmail" returntype="any" returnformat="json">
<cfargument name="accesstoken" default="" required="yes" type="any">
<cfhttp url="googleapis.com/oauth2/v1/userinfo"; method="get" resolveurl="yes" result="httpResult">
<cfhttpparam type="header" name="Authorization" value="OAuth #arguments.accesstoken#">
<cfhttpparam type="header" name="GData-Version" value="3">
</cfhttp>
<cfreturn DeserializeJSON(httpResult.filecontent.toString())>
</cffunction>
I do not what to say, but i used the following method and its seems to bring the email-address, not with new way but with old way:
<cfset googleLogin = objLogin.initiate_login(
loginUrlBase = "https://accounts.google.com/o/oauth2/auth",
loginClientID = application.google_client_id,
loginRedirectURI = application.google_redirecturl,
loginScope = "https://www.googleapis.com/auth/userinfo.email"
)>

I discuss Google+ and Sign In via this blog post (http://www.raymondcamden.com/index.cfm/2014/2/20/Google-SignIn-and-ColdFusion), and yes, I know it is bad to just point to a blog post so none of my hard work there will be appreciated by SO (sigh). As Prisoner said, what you get is based on the scopes initially requested. Here are the docs on additional scopes: https://developers.google.com/+/api/oauth#login-scopes. Email is there, but not phone as far as I see. And to be honest, I don't see a place to enter my phone # at Google+ anyway.

Based on the "getProfileEmail" function that you've added, it looks like you're using the userinfo scope and access point. Google has announced that this method is deprecated and will be removed in September 2014.
You should switch to using the people.get method and adding the email scope to the G+ Sign-in button that Raymond has outlined on his blog.
Update
In your call to objLogin.initiate_login you should change the loginScope parameter to use both the profile and email scopes at a minimum (see https://developers.google.com/+/api/oauth#scopes for a more complete list of scopes you may wish to use). So it might look something like:
<cfset googleLogin = objLogin.initiate_login(
loginUrlBase = "https://accounts.google.com/o/oauth2/auth",
loginClientID = application.google_client_id,
loginRedirectURI = application.google_redirecturl,
loginScope = "profile email"
)>
You can then use the people.get API call to get the information you need. Looking at your getRequest function, however, this appears to call people.get using the API Key, which is insufficient to get email - all it can do is get public information. You need to call people.get in the same way you called userinfo in the getProfileEmail function. I don't know ColdFusion well enough, but you should be able to adapt this function to call the people.get endpoint instead.

Related

CFML and Exchange - CFexchange tags have stopped working

I need a little hand holding to convert my CFML cfexchange tags to the EWS API. I'm using CF 9.0.1 and need to add mail/calendar items to a hosted Exchange server.
I get the following error:
Error:
Could not log in to the Exchange server.
________________________________________
connection="exchangeConn"
server="EXVMBX016-5.exch016.msoutlookonline.net"
username="exch016\j_ttt"
mailboxname="j#ttt.com"
password="[removed]"
Protocol="http"
port="80"
formbasedauthentication="TRUE"
formbasedauthenticationURL="https://owa016.msoutlookonline.net/owa/auth/logon.aspx"
I have come up with the following code so far;
<cffunction name="EWSAddEvent" output="false" returntype="Boolean">
<!--- EWS added by vjl 2013/10/31 --->
<!---
CFExchange in CF server 9 or older will not talk with Exchange 2010 at all, it is promissed to be fixed in CF 10.
As a solution you can use the EWS API. Read the stuff below. I hope my hint is helpfull to you.
---------------------------------------------------------------------- ----------------------
With Exchange 2007 Microsoft abandoned WebDav as an interface to Exchangeserver.
The standard Coldfusion Tags relied on WebDav and will not work anymore.
Since I needed a way to interface with Exchange Server a started looking for possible solutions and this is what i came up with.
In december 2010 Microsoft released the Exchange Managed Services Library for java.
You can find it here: http://archive.msdn.microsoft.com/ewsjavaapi/Release/ProjectReleases.a spx?ReleaseId=5691
In the getting started document it tells you it depends on 4 3rd party libraries which you need to be download separately:
- Apache Commons HttpClient 3.1 (commons-httpclient-3.1.jar)
- Apache Commons Codec 1.4 (commons-codec-1.4.jar)
- Apache Commons Logging 1.1.1 (commons-codec-1.4.jar)
- JCIFS 1.3.15 (jcifs-1.3.15.jar)
With Coldfusion 9.1 (the version I tested with) you only need
- JCIFS 1.3.15 (jcifs-1.3.15.jar) which you can download here: http://jcifs.samba.org/src/
Place the EWS Jar and the JCIFS Jar in your Coldfusion libray folder and after restarting CF server the following code should work.
If you understand this you will be able to figure out your specific needs from the EWS API documentation.
--->
<cfargument name="EmailAddress" type="String" required="True" />
<cfargument name="EventName" type="String" />
<cfargument name="EventStartDateTime" type="Date" />
<cfargument name="EventEndDateTime" type="Date" />
<cfargument name="EventSubject" type="String" />
<cfargument name="EventDescription" type="String" />
<cfargument name="EventLocation" type="String" Required="False" Default="" />
<!--- <cfargument name="EventSensitivity" type="String" Required="False" Default="Normal" />
<cfargument name="EventImportance" type="String" Required="False" Default="Normal" /> --->
<cfargument name="EventReminder" type="String" Required="False" default=0 />
<!--- <cfargument name="Organizer" type="String" Required="False" Default="" /> --->
<cfargument name="OptionalAttendees" type="String" Required="False" Default="" />
<cfargument name="leadID" type="numeric" required="no" default="0" />
<cfargument name="serviceID" type="numeric" required="no" default="0" />
<cfargument name="userID" type="numeric" required="no" default="0" />
<cfargument name="companyID" type="numeric" required="no" default="0" />
<cfargument name="serviceTypeID" type="numeric" required="no" default="0" />
<cfmail to="v#g.com" from="info#t.com" subject="Exchange EWSAddEvent debug Arguments" type="html"><cfdump var="#Arguments#"></cfmail>
<!--- Build Mailbox --->
<cfset UserName = Left(Arguments.EmailAddress,Find("#",Arguments.EmailAddress)-1) />
<cfset Arguments.UserName = Application.Exchange.Domain & "\" & lcase(UserName) & Application.Exchange.MailboxPostFix />
<cfset Arguments.Pword = Trim(FetchExchangePassword(Arguments.EmailAddress)) />
<!--- 1. I need an instance of the ExchangeService class --->
<cfobject type="Java" class="microsoft.exchange.webservices.data.ExchangeService" name="service">
<cfset service.init()>
<cfmail to="v#g.c" from="info#t.com" subject="Exchange EWSAddEvent debug service" type="html"><cfdump var="#service#"></cfmail>
<!--- 2. I need to set the credentials --->
<!--- 2a. Create an instance of the WebCredentials class --->
<cfobject type="Java" class="microsoft.exchange.webservices.data.WebCredentials" name="credentials">
<!--- 2b. Set the credentials --->
<cfset credentials.init("#arguments.UserName#","#Arguments.Pword#", "t.com")>
<!--- 2c. Set the credentials in the service object --->
<cfset service.setCredentials(credentials) />
<!--- 3. In need to set the URL to Exchange (stay away from autodsicovery) --->
<!--- 3a. Create an instance of the Uri class --->
<cfobject type="Java" class="java.net.URI" name="uri">
<!--- 3b. Set the full path --->
<cfset uri.init("https://mail.t.com/ews/Exchange.asmx")>
<!--- 3c. Set the url in the service object --->
<cfset service.setUrl(uri) />
<!--- These are the steps you need to create valid a service object. --->
<!--- Now we need to do something with it. --->
<!--- I create a test message to my own mailbox to see if it works --->
<cfobject type="Java" action="create" class="microsoft.exchange.webservices.data.EmailMessage" name="message">
<cfset message = message.init(service) />
<cfset message.SetSubject("EWSTest")>
<cfset messageBody = CreateObject("java", "microsoft.exchange.webservices.data.MessageBody")>
<cfset messageBody.init("My EWS test message")>
<cfset message.SetBody( messageBody )>
<cfset message.ToRecipients.Add("v#t.com") >
<cfmail to="v#g.c" from="info#t.com" subject="Exchange EWSAddEvent debug message" type="html"><cfdump var="#message#"></cfmail>
<cfoutput>
#message.SendAndSaveCopy()#
</cfoutput>
<cfreturn True />
</cffunction>
Did you get any operation to work using EWS? Or are you facing problem when trying to send mails? If EWS itself is not working for you can you try the following snippet(Change the URL, user name and password) of code?
<cfscript>
service = createObject("java", "microsoft.exchange.webservices.data.ExchangeService");
service.init();
serviceURI = createObject("java", "java.net.URI");
serviceURI.init("http://10.192.37.30/ews/Exchange.asmx");
service.setUrl( serviceURI );
credentials = createObject("java", "microsoft.exchange.webservices.data.WebCredentials");
credentials.init("user", "password");
service.setCredentials(credentials);
folderAPI = createObject("java", "microsoft.exchange.webservices.data.Folder");
folderName = createObject("java", "microsoft.exchange.webservices.data.WellKnownFolderName");
result = folderAPI.bind(service, folderName.Inbox);
writeOutput(result.getDisplayName());
The corresponding java code is
ExchangeService service = new ExchangeService();
URI url = new URI( "http://10.192.37.30/ews/Exchange.asmx" );
service.setUrl( url );
service.setCredentials( new WebCredentials( "username", "password" ) );
System.out.println( "Created ExchangeService" );
Folder folder = Folder.bind( service, WellKnownFolderName.Inbox );
System.out.println( folder.getDisplayName() );
If this works, we can try more complex operations.
Please make sure you are using the correct ASMX URL, user name and password. Try accessing the URL in the browser. Provide the user name and password. If you are able to see the WSDL, then it is fine.
Also make sure that you are using Basic Authentication in Exchange Server.
Thanks,
Paul

Looking for Struct Keys in Session

I am trying to write a session helper and facing to problem to test if a Struct key in session exists?
I am trying like
<cffunction name="Exists" access="public" output="false" returntype="boolean" >
<cfargument name="Key" required="true" type="Any" />
<cfreturn Evaluate( "StructKeyExists( Session, #Arguments.Key# )" ) />
</cffunction>
Where I am calling the function like
<cfif Exists("data.fromdate") >
...
</cfif>
How should I write it?
Thanks
if you are checking to see if key "Test" exists in the session struct, try something like this:
<cffunction name="Exists" access="public" output="false" returntype="boolean" >
<cfargument name="Key" required="true" type="String" />
<cfreturn StructKeyExists(session, arguments.Key) />
</cffunction>
<cfif Exists("Test") >
....
</cfif>
Another concept, or two, since you are looking for a struct within the session would be:
<cffunction name="Exists" access="public" output="false" returntype="boolean" >
<cfargument name="Key" required="true" type="String" />
<cfreturn (structKeyExists(session, listFirst(arguments.Key,"."))
AND structKeyExists(session[listFirst(arguments.Key,".")], listLast(arguments.Key, "."))) />
</cffunction>
<cfif Exists("data.Test") >
....
</cfif>
and
<cffunction name="Exists" access="public" output="false" returntype="boolean" >
<cfargument name="struct" required="true" type="String" />
<cfargument name="Key" required="true" type="String" />
<cfreturn (structKeyExists(session, arguments.struct)
AND structKeyExists(session[arguments.struct], arguments.key)) />
</cffunction>
<cfif Exists("data", "Test") >
....
</cfif>
Hope all this helps point you in the right direction, good luck!
The following code will check any depth struct, and also correctly locks the Session scope.
<cffunction name="Exists" access="public" output="false" returntype="boolean">
<cfargument name="Key" required="true" type="string">
<cfset local.mainKeyList = ListChangeDelims(ListDeleteAt(Arguments.Key, ListLen(Arguments.Key, "."), "."), ",", ".")>
<cfset local.StructChain = "Session">
<cfloop list="#local.mainKeyList#" index="local.CurrentKey">
<cfset local.StructChain &= '["#local.CurrentKey#"]'>
</cfloop>
<cflock scope="session" type="readonly" timeout="3">
<cftry>
<cfset local.Exists = StructKeyExists(Evaluate(local.StructChain), ListLast(Arguments.Key, "."))>
<cfcatch>
<cfset local.Exists = false>
</cfcatch>
</cftry>
</cflock>
<cfreturn local.Exists>
</cffunction>
<cflock scope="session" type="exclusive" timeout="3">
<cfset Session.data.log.deep = "I'm here!">
</cflock>
<cfoutput>#Exists("data.log.deep")#</cfoutput>
Hopefully the amount of code in this function will justify why a helper function would be useful, to those pondering your reasons. This doesn't currently, but could be enhanced to, deal with Structs inside of Arrays as well. This also doesn't deal with an empty Arguments.Key, or fail gracefully on a cflock timeout, but should get you started.
Additionally, those that want to comment that cflock isn't required, please read the ColdFusion cflock docs first.
Simplified, but may provide inaccurate results in extremely rare conditions
Doing an IsDefined inline in your code will provide the opportunity for false positives, however having the IsDefined inside a udf or cfc method reduces this risk greatly to the point it may not need be a consideration. If you're happy to take that chance then you can simplify the function using IsDefined as Peter Boughton suggests.
<cffunction name="Exists" access="public" output="false" returntype="boolean">
<cfargument name="Key" required="true" type="string">
<cflock scope="session" type="readonly" timeout="3">
<cfset local.Exists = IsDefined("Session." & Arguments.Key)>
</cflock>
<cfreturn local.Exists>
</cffunction>
As Al Everett mentioned above, I don't remember the last time I had an app that didn't have session enabled. I guess if you can't be sure of that, then it makes sense to see if Session exists. My code for this would include:
<!--- in the application.cfc --->
<cffunction name="onSessionStart" output="false">
<!--- default session structure, you can also add default values to the data
structure here to ensure they exist later --->
<cfset session.data = {} />
</cffunction>
<!--- then in code use structKeyExists instead of a whole new function --->
<cfif structKeyExists(session.data, myKey)>
<!--- if you really wanted the "exists" function --->
<cffunction name="dataKeyExists" returntype="boolean" output="false">
<cfargument name="key" required="true" />
<cfreturn structKeyExists(session.data, arguments.key) />
</cffunction>
Depending on what's going on, I might choose to pass in the session to maintain encapsulation. But it doesn't always make sense to be a slave to OO and introduce complexity just for the sake of maintaining a pattern. Passing in the session structure and evaluating the key is really just a big workaround to using the "structKeyExists" function.
I also dislike having a function called "exists" because it tells me nothing about what it's really evaluating. I'd assume a function like that was like "isDefined" and more generic than just testing for a key in a specific structure.
<cfif structkeyexists(session, "data") and structkeyexists(session["data"], key)>
...
</cfif>
Why not just call <cfif isNull(session.data.fromdate)>
If the key data does not exist in session it will not throw, just returns false.

consuming coldfusion webservices

I am trying to build a web service. Here is my code for a simple web service which returns a string.
At the beginning i inserted some code from ben nadel
It refreshes the stubfile automatically because otherwise you get errors while passing parameters.
<cfcomponent
displayname="BaseWebService"
output = "false"
hint="This handles core web service features">
<cffunction
name="Init"
access="public"
returntype="any"
output="false"
hint="Returns an initialized web service instance.">
<cfreturn THIS />
</cffunction>
<cffunction
name="RebuildStubFile"
access="remote"
returntype="void"
output="false"
hint="Rebuilds the WSDL file at the given url.">
<cfargument name="Password" type="string" required="true" default="" />
<cfif NOT Compare(ARGUMENTS.Password, "sweetlegs!")>
<cfset CreateObject("java", "coldfusion.server.ServiceFactory"
).XmlRpcService.RefreshWebService(
GetPageContext().GetRequest().GetRequestUrl().Append("?wsdl").ToString()) />
</cfif>
<cfreturn />
</cffunction>
<cffunction
name="easyService"
access="remote"
returntype="any"
output="false">
<cfargument name="anyOutput" type="string" default="this and that" />
<cfargument name="xtype" type="string" required="yes" default="1" />
<cfif Compare(xtype, "1") EQ 0>
<cfset anyVar = "one" />
<cfelse>
<cfset anyVar = "two" />
</cfif>
<cfreturn anyVar>
</cffunction>
</cfcomponent>
Here I am trying to invoke the webservice.
<cfinvoke
webservice="https://[...]/Components/Webservice.cfc?wsdl"
method="RebuildStubFile">
<cfinvokeargument
name="Password"
value="sweetlegs!" />
</cfinvoke>
<cfinvoke
webservice="[...]/Components/Webservice.cfc?wsdl"
method="easyService"
returnVariable="anyVar" >
<cfinvokeargument
name="xtype"
value="2"
omit="true">
</cfinvoke>
<cfdump var="#anyVar#">
The first method of my web service component can be invoked but the second one always returns this error message:
coldfusion.xml.rpc.ServiceProxy$ServiceMethodNotFoundException: Web service operation easyService with parameters {xtype={2}} cannot be found.
at coldfusion.xml.rpc.ServiceProxy.invoke(ServiceProxy.java:149)
at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:2301)
at coldfusion.tagext.lang.InvokeTag.doEndTag(InvokeTag.java:454)
If i type in the url of the webservice, by adding
?method=easyService&xtype=2
it returns the right value. but this is like passing values with a GET method.
i have been searching for hours and don't know where the problem occures.
I think when using WebService call you need to specify all arguments and use omit="true" on the proper one (not on xtype).
<cfinvoke
webservice="[...]/Components/Webservice.cfc?wsdl"
method="easyService"
returnVariable="anyVar" >
<cfinvokeargument
name="anyOutput"
value=""
omit="true">
<cfinvokeargument
name="xtype"
value="2">
</cfinvoke>

What's the most efficient way to redirect a user to the home page if the requested page doesn't exist?

I am using ColdFusion 9.1.
I am rebuilding a site from scratch and pointing an existing domain name to it. The site is still getting a few hits each day and I want to take advantage of that. I want to redirect those page requests to the home page, and not the error that is currently being served.
I am looking ONLY for a ColdFusion solution to move the bad request to the home page. So, if they request domain.com/BadPage.cfm?QString=XYZ, they will be moved to domain.com/.
I tried using the following method in the Application.cfc, but I couldn't get to work as described. It seemed to have no effect.
<cffunction name="OnError" access="public" returntype="void" output="true">
<cfargument name="Exception" type="any" required="true" /">
<cfargument name="EventName" type="string" required="false" default="" />
<cfif Exception>
<cflocation url="http://www.MyDomain.cfom/">
</cfif>
<!--- Return out. --->
<cfreturn />
</cffunction>
In short, what is the simplest ColdFusion means to redirect bad requests?
onError will not catch missing templates. Add an onMissingTemplate Handler to Application.cfc:
<cffunction name="onMissingTemplate" returntype="Boolean" output="false">
<cfargument name="templateName" required="true" type="String" />
<!--- Put your home page file name here --->
<cflocation url="/index.cfm" />
<cfreturn true />
</cffunction>
Use onMissingTemplate()
<cffunction name="onMissingTemplate">
<cfargument type="string" name="targetPage" required=true/>
<cflocation url="http://www.MyDomain.cfom/">
</cffunction>

NTLM Authentication in ColdFusion

Is there a recommended (and preferably free) way in ColdFusion to access a remote file that is protected by NTLM authentication? The cfhttp tag appears to only support Basic authentication.
This CFX Tag - CFX_HTTP5 - should do what you need. It does cost $50, but perhaps it's worth the cost? Seems like a small price to pay.
Here is some code I found in:
http://www.bpurcell.org/downloads/presentations/securing_cfapps_examples.zip
There are also examples for ldap, webservices, and more.. I'll paste 2 files here so you can have an idea, code looks like it should still work.
<cfapplication name="example2" sessionmanagement="Yes" loginStorage="Session">
<!-- Application.cfm -->
<!-- CFMX will check for authentication with each page request. -->
<cfset Request.myDomain="allaire">
<cfif isdefined("url.logout")>
<CFLOGOUT>
</cfif>
<cflogin>
<cfif not IsDefined("cflogin")>
<cfinclude template="loginform.cfm">
<cfabort>
<cfelse>
<!--Invoke NTSecurity CFC -->
<cfinvoke component = "NTSecurity" method = "authenticateAndGetGroups"
returnVariable = "userRoles" domain = "#Request.myDomain#"
userid = "#cflogin.name#" passwd = "#cflogin.password#">
<cfif userRoles NEQ "">
<cfloginuser name = "#cflogin.name#" password = "#cflogin.password#" roles="#stripSpacesfromList(userRoles)#">
<cfset session.displayroles=stripSpacesfromList(userRoles)><!--- for displaying roles only --->
<cfelse>
<cfset loginmessage="Invalid Login">
<cfinclude template="loginform.cfm">
<cfabort>
</cfif>
</cfif>
</cflogin>
<!-- strips leading & trailing spaces from the list of roles that was returned -->
<cffunction name="stripSpacesfromList">
<cfargument name="myList">
<cfset myArray=listtoarray(arguments.myList)>
<cfloop index="i" from="1" to="#arraylen(myArray)#" step="1">
<!--- <cfset myArray[i]=replace(trim(myArray[i]), " ", "_")>
out<br>--->
<cfset myArray[i]=trim(myArray[i])>
</cfloop>
<cfset newList=arrayToList(myArray)>
<cfreturn newList>
</cffunction>
This is the cfc that might be of interest to you:
<!---
This component implements methods for use for NT Authentication and Authorization.
$Log: NTSecurity.cfc,v $
Revision 1.1 2002/03/08 22:40:41 jking
Revision 1.2 2002/06/26 22:46 Brandon Purcell
component for authentication and authorization
--->
<cfcomponent name="NTSecurity" >
<!--- Authenticates the user and outputs true on success and false on failure. --->
<cffunction name="authenticateUser" access="REMOTE" output="no" static="yes" hint="Authenticates the user." returntype="boolean">
<cfargument name="userid" type="string" required="true" />
<cfargument name="passwd" type="string" required="true" />
<cfargument name="domain" type="string" required="true" />
<cftry>
<cfscript>
ntauth = createObject("java", "jrun.security.NTAuth");
ntauth.init(arguments.domain);
// authenticateUser throws an exception if it fails,
ntauth.authenticateUser(arguments.userid, arguments.passwd);
</cfscript>
<cfreturn true>
<cfcatch>
<cfreturn false>
</cfcatch>
</cftry>
</cffunction>
<!---
Authenticates the user and outputs true on success and false on failure.
--->
<cffunction access="remote" name="getUserGroups" output="false" returntype="string" hint="Gets user groups." static="yes">
<cfargument name="userid" type="string" required="true" />
<cfargument name="domain" type="string" required="true" />
<cftry>
<cfscript>
ntauth = createObject("java", "jrun.security.NTAuth");
ntauth.init(arguments.domain);
groups = ntauth.GetUserGroups(arguments.userid);
// note that groups is a java.util.list, which should be
// equiv to a CF array, but it's not right now???
groups = trim(groups.toString());
groups = mid(groups,2,len(groups)-2);
</cfscript>
<cfreturn groups>
<cfcatch>
<cflog text="Error in ntsecurity.cfc method getUserGroups - Error: #cfcatch.message#" type="Error" log="authentication" file="authentication" thread="yes" date="yes" time="yes" application="no">
<cfreturn "">
</cfcatch>
</cftry>
</cffunction>
<!---
This method combines the functionality of authenticateUser and getUserGroups.
--->
<cffunction access="remote" name="authenticateAndGetGroups" output="false" returntype="string" hint="Authenticates the user and gets user groups if it returns nothing the user is not authticated" static="yes">
<cfargument name="userid" type="string" required="true" />
<cfargument name="passwd" type="string" required="true" />
<cfargument name="domain" type="string" required="true" />
<cftry>
<cfscript>
ntauth = createObject("java", "jrun.security.NTAuth");
ntauth.init(arguments.domain);
// authenticateUser throws an exception if it fails,
// so we don't have anything specific here
ntauth.authenticateUser(arguments.userid, arguments.passwd);
groups = ntauth.GetUserGroups(arguments.userid);
// note that groups is a java.util.list, which should be
// equiv to a CF array, but it's not right now
groups = trim(groups.toString());
groups = mid(groups,2,len(groups)-2);
</cfscript>
<cfreturn groups>
<cfcatch>
<cfreturn "">
</cfcatch>
</cftry>
</cffunction>
</cfcomponent>
If the code from Brandon Purcell that uses the jrun.security.NTauth class doesn't work for you in cf9 (it didn't for me) the fix is to use the coldfusion.security.NTAuthentication class instead. Everything worked fine for me.
You could try following the guidance here: http://cfsilence.com/blog/client/index.cfm/2008/3/17/ColdFusionSharepoint-Integration--Part-1--Authenticating
Here is what it boils down to you doing:
edit the client-config.wsdd
Change
<transport
name="http"
pivot="java:org.apache.axis.transport.http.HTTPSender">
</transport>
to
<transport
name="http"
pivot="java:org.apache.axis.transport.http.CommonsHTTPSender">
</transport>
In my case I fixed this problem using 'NTLM Authorization Proxy Server'
http://www.tldp.org/HOWTO/Web-Browsing-Behind-ISA-Server-HOWTO-4.html
work fine for me :)