Pulling Active Directory user attributes into a form/view?


Userlevel 3
Badge +16

Hi all,

 

I had a nice simple form which was originally requested to be used offline and filled in manually, now typically the goalposts have been changed and i've been asked to autopopulate some fields on the views with the currently logged in users details.

 

The fields which I need to autofill are:

 

School

Forename

Surname

UserID

 

I looked into expressions and can use the variable name, but that brings in surname,forneame.

 

My environment is using Sharepoint and Active Directory, so just wondering if anyone could give me some pointers on how to autpopulate these above fields with the necessary info on a view.

 

As always, this noob appreciates your help.


8 replies

Badge +7

If you go to the 100YYZ Lab part 2 it will explain the steps needed to get the user details from Active Directory.


 


Here is a link to the lab:


http://help.k2.com/displaycontent.aspx?id=7160#


 

Userlevel 3
Badge +16

Have you actually read that Lab Part2?

 

I already have that PDF and it says in that guided lab exercise you will display user information from Active Directory, but in reality there is no lab "guided" exercise at all and it just talks about views and has a couple of screenshots, which is quite poor, but there is NO lab, go take a look yourself.

 

Can anyone provide a step by step (i guess this is what was meant to be in that PDF but is badly put together)

Badge +7

I have read that lab, and there is a step by step list starting on page 19 under the section called "Walkthrough".

Badge

There are likely several methods to accomplish this. The problems that I have run into are that the fields/properties I was looking for were not part of the existing service object.

 

From here, depending on your comfort level, there are several options.

The one I chose, being more comfortable with SQL, was to create a SQL Link to active directory, then expose the A.D. data from within a sql view.

Here is an example of how to do this  

Once the view is created, simply create a smart object on it and now all of the properties you were looking for are available for use within your form via the smartobject.

You can use the smartobject to retreive the data based off of the current logged in user.

The speed is not blazing fast, so its not something you would want to pull a large list from, however it works well when querying one item at a time.

 

Userlevel 3
Badge +16

Strange that the steps were not in the PDF i had so i downloaded it again.

 

I have followed the step by step from page 19 onwards and it freezes when I run the list.

 

See screen here: How do i fix this? I have done this to the letter of the steps....

 

12973i13BF259296372D57.jpg

Userlevel 4
Badge +13

Hi SharpSharp


 


I have checked out this request, my findings were.


 


I created a smartobject with a view an set a rule in the view on the "when view is initialized" and "when button is clicked" that retrieves the currently logged in users details, as for the school field that you need - this field will not by in the active directory user details as this would have to be a custom column in a smartobject referenced to each user by school name, for this i created another smartobject and added this rule to the same places as the first rule that i have created - this rule then checks what user is logged in, checks what school he was in and then returnes this value.


 


I have attached a .kspx package, Please use the latest Package and Deployment to deploy the package (NOTE This pagage is only for you to have a look as to how this can be achieved).


 


You will notice in this project that there are two rules in the view "on initialize" and "on button click" both do the same thing. To test each disable the rule you do not want to test, save, finish and test the project.


 


I hope that this is what you were looking for.


 


Kind Regards


Raymond

Userlevel 3
Badge +16

Hi Raymond,

 

Thank you for the package, i've deployed it, but there is an exclamation on the rules, can you tell me what the settings were for the one in the pic...

 

The other thing is, for the display name it shows it as "Domainusername" - is there any way of getting i just to show the username, without the domain in front?

 

Thanks again

 

10685i074093E0D58E289B.jpg

Userlevel 4
Badge +13

Hi SharpSharp1


 


Sure I can, It should be your AD User smartobject. The rule should look like this:


then on AD User SmartObject, execute its GetUserDetails method (Configure)


Rule Configuration:


14042i287657FBA12F59A5.png


 


If you want to test it on initialize, you will have to change the above in the initialize rule as well.


 


As for the username, to remove the Domain from the name. In this project it displays only the name and the surname of the AD User that is currently logged in (Nore DenallixAdministrator will still have the domain name as the user is created to have the domain as part of its name). Test the project with a different user and you will see what i mean.


 


Kind Regards


Raymond

Reply