Send a custom field to take the ad user attribute

Source: Internet
Author: User
In the list, you sometimes need to take the attributes of a user, such as the displayname, department, mobile, and homedirectory of the user. Using the "user or user group" field, this effect cannot be achieved, therefore, this simple custom field is used to fill in the User Login Name and attributes to be displayed when adding/modifying the list item, when displayed, it is displayed by querying the user's relevant attribute values in the ad based on the login name. This item is not yet officially used and is in the testing stage. It can be expanded on this basis, Code Below, it is for reference only.
There are a lot of tutorials on the Development of custom fields. For more information, see erucy's blog. Article . Add a few words below.

The display method defined in fldtypes_custom.xml is defined in <renderpattern name = "displaypattern"/>. For multi-field (inherited from spfieldmulticolumn), the definition XML of this field project is like this: 1 < Renderpattern Name = "Displaypattern" >
2 < Switch >
3 < Expr >
4 < Column />
5 </ Expr >
6 < Case Value = "" >
7 </ Case >
8 < Default >
9 < Column Subcolumnnumber = "0" Htmlencode = "True" />
10 < Html > <! [CDATA [ 'S ]> </ Html >
11 < Column Subcolumnnumber = "1" Htmlencode = "True" />
12 < Html > <! [CDATA [ Is ]> </ Html >
13 < Column Subcolumnnumber = "2" Htmlencode = "True" />
14 </ Default >
15 </ Switch >
16 </ Renderpattern >

He looks like this: PIPIO's department is Development Department. The attribute value of subcolumnnumber corresponds to the attribute in spfieldmulticolumnvalue (which corresponds to the aduserfieldvalue class in this project ).
Then there is a simple way to customize attributes. For example, if ad needs to be connected here, the required custom attributes are also defined in fldtypes_custom.xml. This attribute is: < Propertyschema >
< Fields >
< Field Name = "Domainpath" Displayname = "Domain :" Type = "Text" Required = "True"   />
< Field Name = "Domainusername" Displayname = "Username :" Type = "Text" Required = "True"   />
< Field Name = "Domainpassword" Displayname = "Password :" Type = "Text" Required = "True"   />
</ Fields >
</ Propertyschema >

In the code, use base. field. getcustomproperty ("domainpath") is easy to obtain. Here, there may be a bug. Refer to [solve the problem of incorrect attribute display when custom field type is modified] and fix it by patching, it's almost all hit SP1 now, so this bug should not be there.

Download the code here

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.