272. Araxis Merge File Comparison Report

Produced by Araxis Merge on 2/1/2017 2:56:28 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.

272.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\BusinessDataModel\UsersAndRoles CreateAUser.cs Tue Dec 20 19:51:44 2016 UTC
2 Wed Feb 1 19:56:28 2017 UTC

272.2 Comparison summary

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

272.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

272.4 Active regular expressions

No regular expressions were active.

272.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 CreateAUse r>        
17   using Syst em;        
18   using Syst em.Service Model;        
19   using Syst em.Service Model.Desc ription;        
20          
21   // These n amespaces  are found  in the Mic rosoft.Xrm .Sdk.dll a ssembly        
22   // located  in the SD K\bin fold er of the  SDK downlo ad.        
23   using Micr osoft.Xrm. Sdk;        
24   using Micr osoft.Xrm. Sdk.Query;        
25   using Micr osoft.Xrm. Sdk.Client ;        
26   using Micr osoft.Crm. Sdk.Messag es;        
27          
28   namespace  Microsoft. Crm.Sdk.Sa mples        
29   {        
30       /// <s ummary>        
31       /// De monstrates  how to do  basic ent ity operat ions like  create         
32       /// a  system use r account. </summary>        
33       /// <r emarks>        
34       /// At  run-time,  you will  be given t he option  to delete  all the        
35       /// da tabase rec ords creat ed by this  program.< /remarks>        
36       public  class Cre ateAUser        
37       {        
38           #r egion Clas s Level Me mbers        
39          
40           //  Define th e IDs need ed for thi s sample.        
41           pr ivate Stri ng _domain  = String. Empty;        
42           pr ivate Stri ng _userNa me = "dpar ker";        
43           pr ivate Stri ng _firstN ame = "Dar ren";        
44           pr ivate Stri ng _lastNa me = "Park er";        
45           pr ivate Orga nizationSe rviceProxy  _serviceP roxy;        
46          
47           #e ndregion C lass Level  Members        
48          
49           #r egion How  To Sample  Code        
50           // / <summary >        
51           // / This met hod first  connects t o the Orga nization s ervice. Af terwards,        
52           // / it creat es a syste m user acc ount with  a given ac tive direc tory accou nt.        
53           // / Note: Cr eating a u ser is onl y supporte d in an on -premises/ active dir ectory env ironment.        
54           // / </summar y>        
55           // / <param n ame="serve rConfig">C ontains se rver conne ction info rmation.</ param>        
56           // / <param n ame="promp tforDelete ">When Tru e, the use r will be  prompted t o delete a ll        
57           // / created  entities.< /param>        
58           pu blic void  Run(Server Connection .Configura tion serve rConfig, b ool prompt forDelete)        
59           {        
60                try        
61                {        
62                    //<s nippetCrea teAUser1>        
63                    // C onnect to  the Organi zation ser vice.         
64                    // T he using s tatement a ssures tha t the serv ice proxy  is properl y disposed .        
65                    usin g (_servic eProxy = n ew Organiz ationServi ceProxy(se rverConfig .Organizat ionUri, se rverConfig .HomeRealm Uri,        
66                                                                              s erverConfi g.Credenti als, serve rConfig.De viceCreden tials))        
67                    {        
68                         _servicePr oxy.Enable ProxyTypes ();        
69          
70                         CreateRequ iredRecord s();        
71          
72                         // Retriev e the defa ult busine ss unit ne eded to cr eate the u ser.        
73                         QueryExpre ssion busi nessUnitQu ery = new  QueryExpre ssion        
74                         {        
75                             Entity Name = Bus inessUnit. EntityLogi calName,        
76                             Column Set = new  ColumnSet( "businessu nitid"),        
77                             Criter ia =        
78                             {        
79                                 Co nditions =        
80                         {        
81                             new Co nditionExp ression("p arentbusin essunitid"        
82                                 Co nditionOpe rator.Null )        
83                         }        
84                             }        
85                         };        
86          
87                         BusinessUn it default BusinessUn it = _serv iceProxy.R etrieveMul tiple(        
88                             busine ssUnitQuer y).Entitie s[0].ToEnt ity<Busine ssUnit>();        
89          
90                         //Create a  new syste m user.        
91                         SystemUser  user = ne w SystemUs er        
92                         {        
93                             Domain Name = _do main + _us erName,        
94                             FirstN ame = _fir stName,        
95                             LastNa me = _last Name,        
96                             Busine ssUnitId =  new Entit yReference        
97                             {        
98                                 Lo gicalName  = Business Unit.Entit yLogicalNa me,        
99                                 Na me = Busin essUnit.En tityLogica lName,        
100                                 Id  = default BusinessUn it.Id        
101                             }        
102                         };        
103          
104                         Guid userI d = _servi ceProxy.Cr eate(user) ;        
105          
106                         Console.Wr iteLine("C reated a s ystem user  {0} for ' {1}, {2}'" , userId,  _lastName,  _firstNam e);         
107                    }        
108                    //</ snippetCre ateAUser1>        
109                }        
110                // Catch  any servi ce fault e xceptions  that Micro soft Dynam ics CRM th rows.        
111                catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault>)        
112                {        
113                    // Y ou can han dle an exc eption her e or pass  it back to  the calli ng method.        
114                    thro w;        
115                }        
116           }        
117          
118           // / <summary >        
119           // / Creates  any entity  records t hat this s ample requ ires.        
120           // / </summar y>        
121           pu blic void  CreateRequ iredRecord s()        
122           {        
123                // For t his sample , all requ ired entit ies are cr eated in t he Run() m ethod.        
124                // Obtai n the curr ent user's  informati on.        
125                WhoAmIRe quest who  = new WhoA mIRequest( );        
126                WhoAmIRe sponse who Resp = (Wh oAmIRespon se)_servic eProxy.Exe cute(who);        
127                Guid cur rentUserId  = whoResp .UserId;        
128          
129                SystemUs er current User =        
130                    _ser viceProxy. Retrieve(S ystemUser. EntityLogi calName,         
131                    curr entUserId,          
132                    new  ColumnSet( "domainnam e")).ToEnt ity<System User>();        
133          
134                // Extra ct the dom ain and cr eate the L DAP object .        
135                String[]  userPath  = currentU ser.Domain Name.Split (new char[ ] { '\\' } );        
136                if (user Path.Lengt h > 1)        
137                    _dom ain = user Path[0] +  "\\";        
138                else        
139                    _dom ain = Stri ng.Empty;        
140          
141                SystemUs er existin gUser = Sy stemUserPr ovider.Get UserIdIfEx ist(_servi ceProxy,        
142                    _dom ain, _user Name, _fir stName, _l astName);        
143          
144                if(exist ingUser !=  null)        
145                    thro w new Exce ption("Use r already  exist!");        
146          
147                // Set u p an Activ e Director y account  in the cur rent domai n for this  sample.        
148                String l dapPath =  String.Emp ty;        
149                Boolean  accountSet up = Syste mUserProvi der.Create ADAccount( _userName,          
150                    _fir stName, _l astName, _ servicePro xy, ref ld apPath);        
151                if (acco untSetup)        
152                    Cons ole.WriteL ine("An AD  account c reated for  '{0}, {1} '", _lastN ame, _firs tName);        
153                else        
154                    Cons ole.WriteL ine("AD ac count alre ady exist  for '{0},  {1}'", _la stName, _f irstName);        
155           }        
156          
157           #e ndregion H ow To Samp le Code        
158          
159           #r egion Main  method        
160          
161           // / <summary >        
162           // / Standard  Main() me thod used  by most SD K samples.        
163           // / </summar y>        
164           // / <param n ame="args" ></param>        
165           st atic publi c void Mai n(string[]  args)        
166           {        
167                try        
168                {        
169                    // O btain the  target org anization' s web addr ess and cl ient logon          
170                    // c redentials  from the  user.        
171                    Serv erConnecti on serverC onnect = n ew ServerC onnection( );        
172                    Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on();        
173          
174                    Crea teAUser ap p = new Cr eateAUser( );        
175                    app. Run( confi g, true );        
176                }        
177                catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex )        
178                {        
179                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
180                    Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p);        
181                    Cons ole.WriteL ine("Code:  {0}", ex. Detail.Err orCode);        
182                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Detail. Message);        
183                    Cons ole.WriteL ine("Trace : {0}", ex .Detail.Tr aceText);        
184                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
185                         null == ex .Detail.In nerFault ?  "No Inner  Fault" :  "Has Inner  Fault");        
186                }        
187                catch (S ystem.Time outExcepti on ex)        
188                {        
189                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
190                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Message );        
191                    Cons ole.WriteL ine("Stack  Trace: {0 }", ex.Sta ckTrace);        
192                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
193                         null == ex .InnerExce ption.Mess age ? "No  Inner Faul t" : ex.In nerExcepti on.Message );        
194                }        
195                catch (S ystem.Exce ption ex)        
196                {        
197                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
198                    Cons ole.WriteL ine(ex.Mes sage);        
199          
200                    // D isplay the  details o f the inne r exceptio n.        
201                    if ( ex.InnerEx ception !=  null)        
202                    {        
203                         Console.Wr iteLine(ex .InnerExce ption.Mess age);        
204          
205                         FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e = ex.Inn erExceptio n        
206                             as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>;        
207                         if (fe !=  null)        
208                         {        
209                             Consol e.WriteLin e("Timesta mp: {0}",  fe.Detail. Timestamp) ;        
210                             Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code);        
211                             Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage);        
212                             Consol e.WriteLin e("Trace:  {0}", fe.D etail.Trac eText);        
213                             Consol e.WriteLin e("Inner F ault: {0}" ,        
214                                 nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault");        
215                         }        
216                    }        
217                }        
218                // Addit ional exce ptions to  catch: Sec urityToken Validation Exception,  ExpiredSe curityToke nException ,        
219                // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion.        
220                finally        
221                {        
222                    Cons ole.WriteL ine("Press  <Enter> t o exit.");        
223                    Cons ole.ReadLi ne();        
224                }        
225           }        
226           #e ndregion M ain method        
227       }        
228   }        
229   //</snippe tCreateAUs er>