Latest MCTS 70-573 Dumps Real Exam Download 91-100

Ensurepass

QUESTION 91

You have a custom user profile property named MyProperty.

You need to create a Web Part that displays the value of MyProperty for the current user.

Which code segment should you use?

 

 

A. string profile = SPContext.Current.Web.Properties(“CurrentUser/MyProperty”);

B. string profile = SPContext.Current.Web.Users[“MyProperty”].ToString();

C. UserProfileManager profileManager = new UserProfileManager(SPServiceContext.Current);UserProfile userProfile = profileManager.GetUserProfile(SPContext.Current.Web.CurrentUser.LoginName);string profile = userProfile[“MyProperty”].ToString();

D. UserProfileManager profileManager = new UserProfileManager(SPServiceContext.Current);UserProfile userProfile = profileManager.GetUserProfile(SPContext.Current.Web.CurrentUser.LoginName);string profile = userProfile.Properties.GetPropertyByName(“MyProperty”).ToString();

 

Correct Answer: D

 

Explanation/Reference:

MNEMONIC RULE: GetPropertyByName

userProfile.Properties is ProfileSubtypePropertyManager object. See its members in this MSDN article:

ProfileSubtypePropertyManager Members http://msdn.microsoft.com/en-us/library/ microsoft.office.server.userprofiles.profilesubtypepropertymanager_members.aspx

See the sample code at the link below.

Creating profile properties and sections the SharePoint 2010 way – part 2, The code http://pholpar.wordpress.com/2010/03/17/creating-profile-properties-and-sections-the-sharepoint-2010-way-part-2-the-code/

 

 

QUESTION 92

You need to create a Web Part that adds a term set to the current SharePoint site collection’s term store.

You write the following code segment. (Line numbers are included for reference only.)

01 System.Web.UI.WebControls.TextBox txtBoxTermSetToAdd = new

System.Web.UI.WebControls.TextBox();

02 TaxonomySession session = new TaxonomySession(SPContext.Current.Site);

03 TermSet addedTerm = session.TermStores[0].Groups

[“MyNewTermStore”].CreateTermSet(txtBoxTermSetToAdd.Text);

04

Which code segment should you add at line 04?

 

clip_image002

 

Correct Answer: B

Explanation/Reference:

MNEMONIC RULE: “add a term set = TermStore.CommitAll()”

Term Class

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.taxonomy.term.aspx

 

 

QUESTION 93

You need to create a Web Part that displays all social tags entered by users.

Which code segment should you use?

 

A. TaxonomySession session = new TaxonomySession(SPContext.Current.Site);TermSet socialTags = session.DefaultKeywordsTermStore.SystemGroup.TermSets[“Keywords”];

B. TaxonomySession session = new TaxonomySession(SPContext.Current.Site);

TermSet socialTags = session.DefaultKeywordsTermStore.SystemGroup.TermSets[“Tags”];

C. TermSet socialTags = (TermSet)SPContext.Current.Site.WebApplication.Properties[“Tags”];

D. TermSet socialTags = (TermSet)SPContext.Current.Web.AllProperties[“Keywords”];

 

Correct Answer: A

Explanation/Reference:

MNEMONIC RULE: “TaxonomySession, TermSets[“Keywords”]”

TermSetCollection Members http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.taxonomy.termsetcollection_members.aspx

IndexedCollection<T>.Item Property (String) http://msdn.microsoft.com/en-us/library/ee580616.aspx

 

 

 

clip_image004

A. context.SearchApplication.CrawlStores.Create(args[1]);

B. ManagedPropertyCollection properties = schema.AllManagedProperties;ManagedProperty newMng = properties.Create(args[1], ManagedDataType.Text);

C. ManagedPropertyCollection properties = schema.AllManagedProperties;ManagedProperty newMng = properties.CreateCrawlMonProperty();newMng.Name = args[1];

D. schema.AllCategories.Create(args[1], Guid.NewGuid());

 

Correct Answer: B

Explanation/Reference:

MNEMONIC RULE: “properties.Create()”

Use the AllManagedProperties property of the Schema class to get the collection of managed properties in the Shared Service Provider’s search schema.

To add a new managed property to the collection, use the Create() method.

ManagedPropertyCollection Class http://msdn.microsoft.com/en-us/library/ microsoft.office.server.search.administration.managedpropertycollection.create.aspx

 

 

QUESTION 95

You need to create a Web Part that displays all of the content created by a specific user. You write the following code segment. (Line numbers are included for reference only.)

01 private void keywordQueryExecute(string searchAuthor)

02 {

03 KeywordQuery kRequest = new KeywordQuery(ServerContext.Current);

04

05 kRequest.QueryText = strQuery;

06 ResultTableCollection resultTbls = kRequest.Execute();

07 }

Which code segment should you add at line 04?

 

 

A. string strQuery = “author:” + searchAuthor;

B. string strQuery = “docID:” + searchAuthor;

C. string strQuery = “SELECT Title, Rank, Write, Url FROM SCOPE() WHERE author= ” + searchAuthor;

D. string strQuery = “SELECT Title, Rank, Write, Url FROM SCOPE() WHERE docID =” + searchAuthor;

 

Correct Answer: A

 

Explanation/Reference:

MNEMONIC RULE: “KeywordQuery = no SQL!”

Property Restriction Keyword Queries http://msdn.microsoft.com/en-us/library/ff394509.aspx

 

 

QUESTION 96

You need to create a Web Part that displays all of the content created by a specific user. You write the following code segment. (Line numbers are included for reference only.)

01 FullTextSqlQuery qry = new FullTextSqlQuery(ServerContext.GetContext

(SPContext.Current.Site));

02 qry.ResultTypes = ResultType.RelevantResults;

03

04 qry.QueryText = strQuery;

05 ResultTableCollection results = qry.Execute();

Which code segment should you add at line 03?

 

 

A. string strQuery = “author:” + searchAuthor;

B. string strQuery = “docID:” + searchAuthor;

C. string strQuery = “SELECT Title,Author,Path FROM SCOPE() WHERE author = ‘” +searchAuthor + “‘”;

D. string strQuery = “SELECT Title,Creator,Path FROM SCOPE() WHERE docID = ‘” +searchAuthor + “‘”;

 

Correct Answer: C

Explanation/Reference:

MNEMONIC RULE: “SQL to search for author”

FullTextSqlQuery: Use this class to execute SQL syntax search queries.

Windows SharePoint Services Search Query Object Model http://msdn.microsoft.com/en-us/library/ms455094.aspx

 

 

QUESTION 97

You have a list named Projects that contains a column named ClassificationMetadata.

You need to create a Web Part that updates the ClassificationMetadata value to NA for each item in the Projects list.

You write the following code segment. (Line numbers are included for reference only.)

01 foreach (SPListItem currentItem in SPContext.Current.Web.Lists

[“Projects”].Items)

02 {

03

04 }

Which code segment should you add at line 03?

 

 

A. currentItem[“ClassificationMetadata”] = “NA”;

B. currentItem.Fields[“ClassificationMetadata”].DefaultFormula = “NA”;

C. currentItem.Fields[“ClassificationMetadata”].DefaultValue = “NA”;

D. currentItem[“Value”] = “ClassificationMetadata/NA”;

 

Correct Answer: A

 

Explanation/Reference:

MNEMONIC RULE: “it’s simple: [“ClassificationMetadata”] = “NA””

SPListItem Class http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splistitem.aspx

 

 

QUESTION 98

You create a Web Part that queries a list.

The Web Part contains the following code segment. (Line numbers are included for reference only.)

01 protected override void Render(HtmlTextWriter writer)

02 {

03 SPUserToken spInToken = GetTheContext(SPContext.Current.Site);

04 using (SPSite aSite = new SPSite(curSiteCtx.ID, spInToken))

05 {

06

07 }

08 }

09 private SPUserToken GetTheContext(SPSite nWeb)

10 {

11 nWeb.CatchAccessDeniedException = false;

12 SPUserToken spToken = null;

13 try

14 {

15 spToken = nWeb.SystemAccount.UserToken;

16 }

17 catch (UnauthorizedAccessException generatedExceptionName)

18 {

19

20 }

21 return spToken;

22 }

You need to ensure that users without permissions to the list can view the contents of the list from the Web Part.

Which code segment should you add at line 19?

 

A. SPSecurity.RunWithElevatedPrivileges(delegate(){ using (SPSite eSite = new SPSite(nWeb.ID)){

 spToken = nWeb.SystemAccount.UserToken;

}

}

B. SPSecurity.RunWithElevatedPrivileges(delegate(){

 using (SPSite eSite = new SPSite(nWeb.ID))

{

 spToken = SPContext.Current.Web.CurrentUser.UserToken;

}

}

C. spToken = nWeb.RootWeb.AllUsers[SPContext.Current.Web.Name].UserToken;

D. spToken = nWeb.RootWeb.AllUsers[WindowsIdentity.GetCurrent().Name].UserToken;

 

Correct Answer: A

 

Explanation/Reference:

MNEMONIC RULE: “UnauthorizedAccessException = RunWithElevatedPrivileges = SystemAccount”

Answer A is the only one that will give us a SystemAccount token from within RunWithElevatedPrivileges

statement.

That’s what we are trying to get in case UnauthorizedAccessException occurs.

 

 

QUESTION 99

You create a Web Part that programmatically updates the description of the current SharePoint site.

The Web Part contains the following code segment. (Line numbers are included for reference only.)

01 SPSecurity.RunWithElevatedPrivileges(delegate()

02 {

03 SPSite currSite = SPContext.Current.Site;

04 SPWeb currWeb = SPContext.Current.Web;

05 using (SPSite eSite = new SPSite(currSite.ID))

06 {

07 using (SPWeb eWeb = eSite.OpenWeb(currWeb.ID))

08 {

09 eWeb.AllowUnsafeUpdates = true;

10 currWeb.Description = “Test”;

11 currWeb.Update();

12 eWeb.AllowUnsafeUpdates = false;

13 }

14 }

15 });

Users report that they receive an Access Denied error message when they use the Web Part. You need to ensure that all users can use the Web Part to update the description of the current site.

What should you do?

 

A. Remove lines 09 and 12.

B. Remove lines 10 and 11.

C. Change lines 10 and 11 to use the eWeb variable.

D. Change lines 09 and 12 to use the currWeb variable.

 

Correct Answer: C

Explanation/Reference:

MNEMONIC RULE: “eWeb”

The inner using statement works with eWeb object, so we should use eWeb object all along.

 

 

QUESTION 100

You create a Web Part.

You need to display the number of visits to a SharePoint site collection in a label named LblVisits.

You write the following code segment. (Line numbers are included for reference only.)

01 SPSecurity.RunWithElevatedPrivileges(delegate()02 {

03 04 05  try{ 

06 07 08 09 10  LblVisits.Text = site.Usage.Visits.ToString();}finally{ 

11  }

12 });

Which code segment should you add at line 05?

 

A. SPSite site = new SPSite(SPContext.Current.Site.ID);

B. SPSite site = SPContext.Current.Site;

C. SPSite site = SPContext.GetContext(HttpContext.Current).Site;

D. SPSite site = SPControl.GetContextSite(HttpContext.Current);

 

Correct Answer: A

Explanation/Reference:

MNEMONIC RULE: “new SPSite”

You must create new objects inside the delegate if you need to execute the members of the objects with elevated privileges.

SPSecurity.RunWithElevatedPrivileges Method http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsecurity.runwithelevatedprivileges (v=office.14).aspx

 

Download Lates MCTS 70-573 Real Free Tests , help you to pass exam 100%.