I should say, migration from JDeveloper 11g PS1 to PS2 went very smoothly for us - we didn't noticed any significant problems. However, there is one issue with getUserPrincipalName() method, when you want to get current user name from ADF BC. Thanks to Steve Muench, there is already bug logged on Oracle Metalink - bug# 9672139. There are also good news about security, we don't have anymore these annoying security warnings in the log, for every protected resource. Today I will tell you, how you can get logged in user name in prepareSession() method, until mentioned bug will be fixed.
Download sample application - GetUserPrincipalADFModel.zip. This sample shows two approaches how to get logged in user name in ADF BC. One of them works and another no. Hopefully in next release, both of them will work. Because we were using getUserPrincipalName() method, and it stopped working, we moved to second approach - to get logged in user name through ADF Context.
We need to get logged in user name in Application Module Implementation class:
I override framework method - prepareSession(), will get user name in this method. Its especially useful, if you need to inform database, about current web user name. First approach to get logged in user name is based on this.getUserPrincipalName() (currently not working) and second accessing ADF Context:
There is one user declared in the jazn - scott/welcome1:
Let's test it a bit. If we run ADF BC tester - both approaches work well and print currently logged in user name:
Now we run Web part and log in into application - you can see user scott is logged in:
But if we check the log - only ADF Context returns correct user name in prepareSession() method. When we access this.getUserPrincipalName directly, anonymous is returned - it is incorrect:
So, for now get logged in user name on ADF BC level from ADF Context object.