452. Araxis Merge File Comparison Report

Produced by Araxis Merge on 2/1/2017 2:56:46 PM Eastern Standard Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

452.1 Files compared

# Location File Last Modified
1 C:\Araxis_Merge_Comprasion\Pub_un\BTSSS_CIF_122016.zip\BTSSS_CIF_12_20_16\clean\CRM\trunk\SDK\SampleCode\CS\HelperCode SystemUserProvider.cs Tue Dec 20 19:51:44 2016 UTC
2 Wed Feb 1 19:56:46 2017 UTC

452.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 0 0
Changed 0 0
Inserted 0 0
Removed 1 473

452.3 Comparison options

Whitespace
Character case Differences in character case are significant
Line endings Differences in line endings (CR and LF characters) are ignored
CR/LF characters Not shown in the comparison detail

452.4 Active regular expressions

No regular expressions were active.

452.5 Comparison detail

1   // ======= ========== ========== ========== ========== ========== ========== ==        
2   //  This f ile is par t of the M icrosoft D ynamics CR M SDK code  samples.        
3   //        
4   //  Copyri ght (C) Mi crosoft Co rporation.   All righ ts reserve d.        
5   //        
6   //  This s ource code  is intend ed only as  a supplem ent to Mic rosoft        
7   //  Develo pment Tool s and/or o n-line doc umentation .  See the se other        
8   //  materi als for de tailed inf ormation r egarding M icrosoft c ode sample s.        
9   //        
10   //  THIS C ODE AND IN FORMATION  ARE PROVID ED "AS IS"  WITHOUT W ARRANTY OF  ANY        
11   //  KIND,  EITHER EXP RESSED OR  IMPLIED, I NCLUDING B UT NOT LIM ITED TO TH E        
12   //  IMPLIE D WARRANTI ES OF MERC HANTABILIT Y AND/OR F ITNESS FOR  A        
13   //  PARTIC ULAR PURPO SE.        
14   // ======= ========== ========== ========== ========== ========== ========== ==        
15          
16   //<snippet SystemUser Provider>        
17   using Syst em;        
18   using Syst em.Collect ions.Gener ic;        
19   using Syst em.Directo ryServices ;        
20   using Syst em.Threadi ng;        
21          
22   // These n amespaces  are found  in the Mic rosoft.Xrm .Sdk.dll a ssembly        
23   // located  in the SD K\bin fold er of the  SDK downlo ad.        
24   using Micr osoft.Xrm. Sdk;        
25   using Micr osoft.Xrm. Sdk.Query;        
26   using Micr osoft.Xrm. Sdk.Client ;        
27   using Micr osoft.Xrm. Sdk.Messag es;        
28          
29   // This na mespace is  found in  the Micros oft.Crm.Sd k.Proxy.dl l assembly        
30   // located  in the SD K\bin fold er of the  SDK downlo ad.        
31   using Micr osoft.Crm. Sdk.Messag es;        
32          
33   namespace  Microsoft. Crm.Sdk.Sa mples        
34   {        
35       /// <s ummary>        
36       /// Th is class c ontains me thods whic h retrieve  the IDs o f several  fictitious  Microsoft  Dynamics        
37       /// CR M system u sers.  Sev eral SDK s amples req uire these  additiona l user acc ounts in o rder to ru n.        
38       /// </ summary>        
39       /// <r emarks>For  On-premis es and IFD  deploymen ts, if the se users d o not exis t they are  created i n        
40       /// Ac tive Direc tory. This  assumes t hat the sy stem user  account un der which  the applic ation runs  has        
41       /// sy stem admin istrator p rivileges.  Since it  is not pos sible to p rogrammati cally crea te user ac counts        
42       /// in  Microsoft  account,  when runni ng this co de against  a Microso ft Dynamic s CRM Onli ne server,  you will  have        
43       /// to  manually  add these  users.</re marks>        
44       public  class Sys temUserPro vider        
45       {        
46           pu blic stati c Guid Ret rieveSales Manager(Or ganization ServicePro xy proxy)        
47           {        
48                String l dapPath =  String.Emp ty;        
49                return R etrieveSys temUser("k cook", "Ke vin", "Coo k", "Sales  Manager",  proxy, re f ldapPath );        
50           }        
51           pu blic stati c Guid Ret rieveSales Manager(Or ganization ServicePro xy proxy,  ref String  ldapPath)        
52           {        
53                return R etrieveSys temUser("k cook", "Ke vin", "Coo k", "Sales  Manager",  proxy, re f ldapPath );        
54           }        
55          
56           pu blic stati c List<Gui d> Retriev eSalespers ons(Organi zationServ iceProxy p roxy, ref  String lda pPath)        
57           {        
58                List<Gui d> reps =  new List<G uid>();        
59          
60                reps.Add (RetrieveS ystemUser( "nanderson ", "Nancy" , "Anderso n", "Sales person", p roxy, ref  ldapPath)) ;        
61                reps.Add (RetrieveS ystemUser( "dbristol" , "David",  "Bristol" , "Salespe rson", pro xy, ref ld apPath));        
62          
63                return r eps;        
64           }        
65          
66           pu blic stati c List<Gui d> Retriev eDelegates (Organizat ionService Proxy prox y,        
67                ref Stri ng ldapPat h)        
68           {        
69                List<Gui d> delegat es = new L ist<Guid>( );        
70          
71                delegate s.Add(Retr ieveSystem User("dwil son", "Dan ", "Wilson ", "Delega te", proxy , ref ldap Path));        
72                delegate s.Add(Retr ieveSystem User("cand erson", "C hristen",  "Anderson" , "Delegat e", proxy,  ref ldapP ath));        
73                return d elegates;        
74           }        
75          
76           pu blic stati c Guid Ret rieveVPSal es(Organiz ationServi ceProxy pr oxy, ref S tring ldap Path)        
77           {        
78                return R etrieveSys temUser("m tucker", " Michael",  "Tucker",  "Vice Pres ident of S ales", pro xy, ref ld apPath);        
79           }        
80          
81           pu blic stati c Guid Ret rieveMarke tingManage r(Organiza tionServic eProxy pro xy)        
82           {        
83                String l dapPath =  String.Emp ty;        
84                return R etrieveMar ketingMana ger(proxy,  ref ldapP ath);        
85           }        
86          
87           pu blic stati c Guid Ret rieveMarke tingManage r(Organiza tionServic eProxy pro xy, ref St ring ldapP ath)        
88           {        
89                return R etrieveSys temUser("s smith", "S amantha",  "Smith", " Marketing  Manager",  proxy, ref  ldapPath) ;        
90           }        
91          
92           pu blic stati c Guid Ret rieveAUser WithoutAny RoleAssign ed(Organiz ationServi ceProxy pr oxy)        
93           {        
94                String l dapPath =  String.Emp ty;        
95                return R etrieveSys temUser("d park", "Da n", "Park" , "", prox y, ref lda pPath);        
96           }        
97          
98           // / <summary >        
99           // / Retrieve s the requ ested Syst emUser rec ord.  If t he record  does not e xist, a ne w        
100           // / Microsof t Dynamics  CRM Syste mUser reco rd is crea ted and an  associate d Active        
101           // / Director y account  is created , if it do esn't curr ently exis t.        
102           // / </summar y>        
103           // / <param n ame="userN ame">The u sername fi eld as set  in Micros oft Dynami cs CRM</pa ram>        
104           // / <param n ame="first Name">The  first name  of the sy stem user  to be retr ieved</par am>        
105           // / <param n ame="lastN ame">The l ast name o f the syst em user to  be retrie ved</param >        
106           // / <param n ame="roleS tr">The st ring repre senting th e Microsof t Dynamics  CRM secur ity        
107           // / role for  the user< /param>        
108           // / <param n ame="servi ceProxy">T he Organiz ationServi ceProxy ob ject to yo ur Microso ft        
109           // / Dynamics  CRM envir onment</pa ram>        
110           // / <param n ame="ldapP ath">The L DAP path f or your ne twork - yo u can eith er call        
111           // / ConsoleP romptForLD APPath() t o prompt t he user or  provide a  value in  code</para m>        
112           // / <returns ></returns >        
113           pu blic stati c Guid Ret rieveSyste mUser(Stri ng userNam e, String  firstName,        
114                String l astName, S tring role Str, Organ izationSer viceProxy  servicePro xy,        
115                ref Stri ng ldapPat h)        
116           {        
117                String d omain;        
118                Guid use rId = Guid .Empty;        
119          
120                if (serv iceProxy = = null)        
121                    thro w new Argu mentNullEx ception("s erviceProx y");        
122          
123                if (Stri ng.IsNullO rWhiteSpac e(userName ))        
124                    thro w new Argu mentNullEx ception("U serName");        
125          
126                if (Stri ng.IsNullO rWhiteSpac e(firstNam e))        
127                    thro w new Argu mentNullEx ception("F irstName") ;        
128          
129                if (Stri ng.IsNullO rWhiteSpac e(lastName ))        
130                    thro w new Argu mentNullEx ception("L astName");        
131          
132                // Obtai n the curr ent user's  informati on.        
133                WhoAmIRe quest who  = new WhoA mIRequest( );        
134                WhoAmIRe sponse who Resp = (Wh oAmIRespon se)service Proxy.Exec ute(who);        
135                Guid cur rentUserId  = whoResp .UserId;        
136          
137                SystemUs er current User =        
138                    serv iceProxy.R etrieve(Sy stemUser.E ntityLogic alName, cu rrentUserI d, new Col umnSet("do mainname") ).ToEntity <SystemUse r>();        
139          
140                // Extra ct the dom ain and cr eate the L DAP object .        
141                String[]  userPath  = currentU ser.Domain Name.Split (new char[ ] { '\\' } );        
142                if (user Path.Lengt h > 1)        
143                    doma in = userP ath[0] + " \\";        
144                else        
145                    doma in = Strin g.Empty;        
146          
147          
148          
149                SystemUs er existin gUser = Ge tUserIdIfE xist(servi ceProxy, d omain, use rName, fir stName, la stName);        
150          
151          
152                if (exis tingUser ! = null)        
153                {        
154                    user Id = exist ingUser.Sy stemUserId .Value;        
155          
156                    if ( !String.Is NullOrWhit eSpace(rol eStr))        
157                    {        
158                         // Check t o make sur e the user  is assign ed the cor rect role.        
159                         Role role  = Retrieve RoleByName (servicePr oxy, roleS tr);        
160          
161                         // Associa te the use r with the  role when  needed.        
162                         if (!UserI nRole(serv iceProxy,  userId, ro le.Id))        
163                         {        
164                             Associ ateRequest  associate  = new Ass ociateRequ est()        
165                             {        
166                                 Ta rget = new  EntityRef erence(Sys temUser.En tityLogica lName, use rId),        
167                                 Re latedEntit ies = new  EntityRefe renceColle ction()        
168                             {        
169                                 ne w EntityRe ference(Ro le.EntityL ogicalName , role.Id)        
170                             },        
171                                 Re lationship  = new Rel ationship( "systemuse rroles_ass ociation")        
172                             };        
173                             servic eProxy.Exe cute(assoc iate);        
174                         }        
175                    }        
176                }        
177                else        
178                {        
179                    // C reate the  system use r in Micro soft Dynam ics CRM if  the user  doesn't         
180                    // a lready exi st.        
181                    user Id = Creat eSystemUse r(userName , firstNam e, lastNam e, domain,        
182                         roleStr, s erviceProx y, ref lda pPath);        
183                }        
184          
185                return u serId;        
186           }        
187          
188           // / <summary >        
189           // / Helper m ethod to c heck if sy stem user  already ex ist with e ither give n username  or first  and last n ame.        
190           // / </summar y>        
191           // / <param n ame="servi ceProxy">T he Organiz ationServi ceProxy ob ject to yo ur Microso ft        
192           // / Dynamics  CRM envir onment</pa ram>        
193           // / <param n ame="domai nName">Cur rent domai n name of  the accoun t.</param>        
194           // / <param n ame="userN ame">The u sername fi eld as set  in Micros oft Dynami cs CRM</pa ram>        
195           // / <param n ame="first Name">The  first name  of the sy stem user  to be retr ieved</par am>        
196           // / <param n ame="lastN ame">The l ast name o f the syst em user to  be retrie ved</param >        
197           // / <returns ></returns >        
198           pu blic stati c SystemUs er GetUser IdIfExist( Organizati onServiceP roxy servi ceProxy,        
199                String d omainName,  String us erName, St ring first Name, Stri ng lastNam e)        
200           {        
201                QueryExp ression us erQuery =  new QueryE xpression        
202                {        
203                    Enti tyName = S ystemUser. EntityLogi calName,        
204                    Colu mnSet = ne w ColumnSe t("systemu serid"),        
205                    Crit eria =        
206                    {        
207                         FilterOper ator = Log icalOperat or.Or,        
208                         Filters =        
209                         {           
210                             new Fi lterExpres sion        
211                             {        
212                                 Fi lterOperat or = Logic alOperator .And,        
213                                 Co nditions =        
214                                 {        
215                                      new Cond itionExpre ssion("dom ainname",  ConditionO perator.Eq ual, domai nName + us erName)        
216                                 }        
217                             },        
218                             new Fi lterExpres sion        
219                             {        
220                                 Fi lterOperat or = Logic alOperator .And,        
221                                 Co nditions =          
222                                 {        
223                                      new Cond itionExpre ssion("fir stname", C onditionOp erator.Equ al, firstN ame),        
224                                      new Cond itionExpre ssion("las tname", Co nditionOpe rator.Equa l, lastNam e)        
225                                 }        
226                             }        
227                         }        
228          
229                    }        
230                };        
231          
232                DataColl ection<Ent ity> exist ingUsers =  (DataColl ection<Ent ity>)servi ceProxy.Re trieveMult iple(userQ uery).Enti ties;        
233          
234                if (exis tingUsers. Count > 0)        
235                    retu rn existin gUsers[0]. ToEntity<S ystemUser> ();        
236                return n ull;        
237           }        
238          
239           pr ivate stat ic Guid Cr eateSystem User(Strin g userName , String f irstName,        
240                String l astName, S tring doma in, String  roleStr,        
241                Organiza tionServic eProxy ser viceProxy,  ref Strin g ldapPath )        
242           {        
243                CreateAD Account(us erName, fi rstName, l astName, s erviceProx y, ref lda pPath);        
244          
245                // Retri eve the de fault busi ness unit  needed to  create the  user.        
246                QueryExp ression bu sinessUnit Query = ne w QueryExp ression        
247                {        
248                    Enti tyName = B usinessUni t.EntityLo gicalName,        
249                    Colu mnSet = ne w ColumnSe t("busines sunitid"),        
250                    Crit eria =        
251                    {        
252                         Conditions  =        
253                         {        
254                             new Co nditionExp ression("p arentbusin essunitid"        
255                                 Co nditionOpe rator.Null )        
256                         }        
257                    }        
258                };        
259          
260                Business Unit defau ltBusiness Unit = ser viceProxy. RetrieveMu ltiple(        
261                    busi nessUnitQu ery).Entit ies[0].ToE ntity<Busi nessUnit>( );        
262          
263                //Create  a new sys tem user.        
264                SystemUs er user =  new System User        
265                {        
266                    Doma inName = d omain + us erName,        
267                    Firs tName = fi rstName,        
268                    Last Name = las tName,        
269                    Busi nessUnitId  = new Ent ityReferen ce        
270                    {        
271                         LogicalNam e = Busine ssUnit.Ent ityLogical Name,        
272                         Name = Bus inessUnit. EntityLogi calName,        
273                         Id = defau ltBusiness Unit.Id        
274                    }        
275                };        
276                Guid use rId = serv iceProxy.C reate(user );        
277          
278                if (!Str ing.IsNull OrWhiteSpa ce(roleStr ))        
279                {        
280                    // R etrieve th e specifie d security  role.        
281                    Role  role = Re trieveRole ByName(ser viceProxy,  roleStr);        
282          
283                    // A ssign the  security r ole to the  newly cre ated Micro soft Dynam ics CRM us er.        
284                    Asso ciateReque st associa te = new A ssociateRe quest()        
285                    {        
286                         Target = n ew EntityR eference(S ystemUser. EntityLogi calName, u serId),        
287                         RelatedEnt ities = ne w EntityRe ferenceCol lection()        
288                    {        
289                         new Entity Reference( Role.Entit yLogicalNa me, role.I d),        
290                    },        
291                         Relationsh ip = new R elationshi p("systemu serroles_a ssociation ")        
292                    };        
293                    serv iceProxy.E xecute(ass ociate);        
294                }        
295                return u serId;        
296           }        
297          
298           // / <summary >        
299           // / Helper m ethod to c reate an a ctive dire ctory acco unt        
300           // / </summar y>        
301           // / <param n ame="userN ame">The u sername fi eld as set  in Micros oft Dynami cs CRM</pa ram>        
302           // / <param n ame="first Name">The  first name  of the sy stem user  to be retr ieved</par am>        
303           // / <param n ame="lastN ame">The l ast name o f the syst em user to  be retrie ved</param >        
304           // / <param n ame="servi ceProxy">T he Organiz ationServi ceProxy ob ject to yo ur Microso ft        
305           // / Dynamics  CRM envir onment</pa ram>        
306           // / <param n ame="ldapP ath">The L DAP path f or your ne twork - yo u can eith er call        
307           // / ConsoleP romptForLD APPath() t o prompt t he user or  provide a  value in  code</para m>        
308           // / <returns >Return tr ue if new  account is  created o r return f alse if ac count alre ady exist. </returns>        
309           pu blic stati c Boolean  CreateADAc count(Stri ng userNam e,        
310                String f irstName,        
311                String l astName,        
312                Organiza tionServic eProxy ser viceProxy,        
313                ref Stri ng ldapPat h)        
314           {        
315                // Check  to make s ure this i s not Micr osoft Dyna mics CRM O nline.        
316                if (serv iceProxy.S erviceConf iguration. Authentica tionType = = Authenti cationProv iderType.L iveId ||        
317                    serv iceProxy.S erviceConf iguration. Authentica tionType = = Authenti cationProv iderType.O nlineFeder ation)        
318                    thro w new Exce ption(Stri ng.Format( "To run th is sample,  {0} {1} m ust be an  active sys tem user "  +        
319                         "\nin your  Microsoft  Dynamics  CRM Online  organizat ion.", fir stName, la stName));        
320          
321                if (Stri ng.IsNullO rEmpty(lda pPath))        
322                    ldap Path = Sys temUserPro vider.Cons olePromptF orLDAPPath ();        
323          
324                // Creat e an Activ e Director y user acc ount if it  doesn't e xist alrea dy.        
325                if (Stri ng.IsNullO rEmpty(lda pPath))        
326                    thro w new Argu mentExcept ion("Requi red argume nt ldapPat h was not  provided." );        
327          
328                Director yEntry dir ectoryEntr y;        
329                if (serv iceProxy.C lientCrede ntials.Win dows != nu ll)        
330                {        
331                    stri ng LUser =  servicePr oxy.Client Credential s.Windows. ClientCred ential.Use rName;        
332                    stri ng LPwd =  servicePro xy.ClientC redentials .Windows.C lientCrede ntial.Pass word;        
333                    dire ctoryEntry  = new Dir ectoryEntr y(ldapPath , LUser, L Pwd);        
334                }        
335                else        
336                {        
337                    dire ctoryEntry  = new Dir ectoryEntr y(ldapPath );        
338                }        
339          
340                Director yEntry use rADAccount  = null;        
341          
342                // Searc h AD to se e if the u ser alread y exists.        
343                Director ySearcher  search = n ew Directo rySearcher (directory Entry);        
344                search.F ilter = St ring.Forma t("(sAMAcc ountName={ 0})", user Name);        
345                search.P ropertiesT oLoad.Add( "samaccoun tname");        
346                search.P ropertiesT oLoad.Add( "givenname ");        
347                search.P ropertiesT oLoad.Add( "sn");        
348                search.P ropertiesT oLoad.Add( "cn");        
349                SearchRe sult resul t = search .FindOne() ;        
350                Boolean  accountCre ated = fal se;        
351                if (resu lt == null )        
352                {        
353                    // C reate the  Active Dir ectory acc ount.         
354                    user ADAccount  = director yEntry.Chi ldren.Add( "CN= " + u serName, " user");        
355                    user ADAccount. Properties ["samAccou ntName"].V alue = use rName;        
356                    user ADAccount. Properties ["givenNam e"].Value  = firstNam e;        
357                    user ADAccount. Properties ["sn"].Val ue = lastN ame;        
358                    user ADAccount. CommitChan ges();        
359                    acco untCreated  = true;        
360                }        
361                else        
362                {        
363                    // U se the exi sting AD a ccount.        
364                    user ADAccount  = result.G etDirector yEntry();        
365                    acco untCreated  = false;        
366                }        
367          
368                // Set t he passwor d for the  account.        
369                String p assword =  "pass@word 1";        
370                userADAc count.Invo ke("SetPas sword", ne w object[]  { passwor d });        
371                userADAc count.Comm itChanges( );        
372                director yEntry.Clo se();        
373                userADAc count.Clos e();        
374          
375                // Enabl e the newl y created  Active Dir ectory acc ount.        
376                userADAc count.Prop erties["us erAccountC ontrol"].V alue =        
377                    (int )userADAcc ount.Prope rties["use rAccountCo ntrol"].Va lue & ~0x2 ;        
378                userADAc count.Comm itChanges( );        
379          
380                // Wait  10 seconds  for the A D account  to propaga te.        
381                Thread.S leep(10000 );        
382                return a ccountCrea ted;        
383           }        
384          
385           // / <summary >        
386           // / Helper m ethod to p rompt the  user for t he LDAP pa th for the  network        
387           // / </summar y>        
388           // / <returns >The LDAP  path for y our networ k</returns >        
389           pu blic stati c String C onsoleProm ptForLDAPP ath()        
390           {        
391                // Promp t for the  LDAP path.        
392                Console. WriteLine( "An Active  Directory  connectio n is requi red. Pleas e enter an ");        
393                Console. WriteLine( "LDAP path  for your  network in  the forma t 'LDAP:// server/DC= subdomain, DC=domain, DC=com': " );        
394                String l dapPath =  Console.Re adLine();        
395          
396                return l dapPath;        
397           }        
398          
399           pr ivate stat ic bool Us erInRole(O rganizatio nServicePr oxy servic eProxy,        
400                Guid use rId, Guid  roleId)        
401           {        
402                // Estab lish a Sys temUser li nk for a q uery.        
403                LinkEnti ty systemU serLink =  new LinkEn tity()        
404                {        
405                    Link FromEntity Name = Sys temUserRol es.EntityL ogicalName ,        
406                    Link FromAttrib uteName =  "systemuse rid",        
407                    Link ToEntityNa me = Syste mUser.Enti tyLogicalN ame,        
408                    Link ToAttribut eName = "s ystemuseri d",        
409                    Link Criteria =        
410                    {        
411                         Conditions  =         
412                         {        
413                             new Co nditionExp ression(        
414                                 "s ystemuseri d", Condit ionOperato r.Equal, u serId)        
415                         }        
416                    }        
417                };        
418          
419                // Build  the query .        
420                QueryExp ression qu ery = new  QueryExpre ssion()        
421                {        
422                    Enti tyName = R ole.Entity LogicalNam e,        
423                    Colu mnSet = ne w ColumnSe t("roleid" ),        
424                    Link Entities =          
425                    {        
426                         new LinkEn tity()        
427                         {        
428                             LinkFr omEntityNa me = Role. EntityLogi calName,        
429                             LinkFr omAttribut eName = "r oleid",        
430                             LinkTo EntityName  = SystemU serRoles.E ntityLogic alName,        
431                             LinkTo AttributeN ame = "rol eid",        
432                             LinkEn tities = { systemUser Link}        
433                         }        
434                    },        
435                    Crit eria =        
436                    {        
437                         Conditions  =         
438                         {        
439                             new Co nditionExp ression("r oleid", Co nditionOpe rator.Equa l, roleId)        
440                         }        
441                    }        
442                };        
443          
444                // Retri eve matchi ng roles.        
445                EntityCo llection e c = servic eProxy.Ret rieveMulti ple(query) ;        
446          
447                if (ec.E ntities.Co unt > 0)        
448                    retu rn true;        
449          
450                return f alse;        
451           }        
452          
453           pr ivate stat ic Role Re trieveRole ByName(Org anizationS erviceProx y serviceP roxy,        
454                String r oleStr)        
455           {        
456                QueryExp ression ro leQuery =  new QueryE xpression        
457                {        
458                    Enti tyName = R ole.Entity LogicalNam e,        
459                    Colu mnSet = ne w ColumnSe t("roleid" ),        
460                    Crit eria =        
461                    {        
462                         Conditions  =        
463                         {        
464                             new Co nditionExp ression("n ame", Cond itionOpera tor.Equal,  roleStr)        
465                         }        
466                    }        
467                };        
468          
469                return s erviceProx y.Retrieve Multiple(r oleQuery). Entities[0 ].ToEntity <Role>();        
470           }        
471       }        
472   }        
473   //</snippe tSystemUse rProvider>