| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372 |
- /** BEGIN COPYRIGHT BLOCK
- * This Program is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free Software
- * Foundation; version 2 of the License.
- *
- * This Program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * In addition, as a special exception, Red Hat, Inc. gives You the additional
- * right to link the code of this Program with code not covered under the GNU
- * General Public License ("Non-GPL Code") and to distribute linked combinations
- * including the two, subject to the limitations in this paragraph. Non-GPL Code
- * permitted under this exception must only link to the code of this Program
- * through those well defined interfaces identified in the file named EXCEPTION
- * found in the source code files (the "Approved Interfaces"). The files of
- * Non-GPL Code may instantiate templates or use macros or inline functions from
- * the Approved Interfaces without causing the resulting work to be covered by
- * the GNU General Public License. Only Red Hat, Inc. may make changes or
- * additions to the list of Approved Interfaces. You must obey the GNU General
- * Public License in all respects for all of the Program code and other code used
- * in conjunction with the Program except the Non-GPL Code covered by this
- * exception. If you modify this file, you may extend this exception to your
- * version of the file, but you are not obligated to do so. If you do not wish to
- * provide this exception without modification, you must delete this exception
- * statement from your version and license this file solely under the GPL without
- * exception.
- *
- *
- * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
- * Copyright (C) 2005 Red Hat, Inc.
- * All rights reserved.
- * END COPYRIGHT BLOCK **/
- ///////////////////////////////////////////////////////////////////////////////
- // dsinst.c - Fedora Directory Server Installation Plug-In
- //
- #include <windows.h>
- #include <commctrl.h>
- #include <nssetup.h>
- #include <ldapu.h>
- #include <time.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <stdio.h>
- #include <process.h>
- #include <regstr.h>
- #include <ldap.h>
- #include <wingdi.h>
- #include "resource.h"
- #include "dsinst.h"
- #include "install_keywords.h"
- #include "libinst.h"
- #ifdef TARGETDIR
- #undef TARGETDIR
- #endif
- #define NUM_PROP_PAGES 16
- // this is the path to perl, relative to the server root directory
- #define PERL_EXE "bin\\slapd\\admin\\bin\\perl.exe"
- // this is the keyword to lookup in slapd.inf
- #define NSPERL_POST_INSTALL_PROG "NSPerlPostInstall"
- #define INDEX_FIRST_PAGE 0
- #define INDEX_LAST_PAGE 14
- #define NUM_CIR_ATTR 12
- #define NUM_ORC_ATTR 1
- #define NUM_SIR_ATTR 10
- static MODULEINFO mi = {
- NULL, // m_hModule
- NULL, // m_hwndParent
- NS_WIZERROR, // m_nResult
- 0, // m_nReInstall
- NULL, // m_szMCCBindAs
- };
- static INFDATA cd;
- static void normalizeDNs();
- extern int ds_dn_uses_LDAPv2_quoting(const char *utf8dn);
- extern char *dn_normalize_convert(char *dn);
- static void fixDN(char *dn);
- static char *dialogMessage; /* used by shutdownDialogProc */
- #define OLD_VERSION_SIZE 32
- static char oldVersion[OLD_VERSION_SIZE]; /* used by reinstall */
- static int
- my_snprintf(char *s, size_t size, const char *fmt, ...)
- {
- int rc;
- va_list ap;
- va_start(ap, fmt);
- rc = _vsnprintf(s, size, fmt, ap);
- va_end(ap);
- s[size-1] = (char)0;
- return rc;
- }
- static void
- my_strncpy(char *dst, const char *src, size_t size)
- {
- strncpy(dst, src, size-1);
- dst[size-1] = (char)0;
- }
- static void
- storeUserDirectoryInfo()
- {
- char *utf8UserGroupAdmin = NULL;
- char *utf8UserGroupAdminPW = NULL;
- char *utf8UserGroupURL = NULL;
- if (mi.m_nReInstall == 1)
- return; // do nothing if reinstall
- if(mi.m_nExistingUG == 0)
- {
- /* the user is creating a new UG with this instance */
- if(mi.m_nExistingMCC == 0)
- {
- /* the user is also creating a new MCC so set UG admin to MCC admin */
- my_strncpy(mi.m_szUserGroupAdmin, mi.m_szMCCBindAs, sizeof(mi.m_szUserGroupAdmin));
- my_strncpy(mi.m_szUserGroupAdminPW, mi.m_szMCCPw, sizeof(mi.m_szUserGroupAdminPW));
- }else{
- /* user is using an existing MCC so only creating UG, make UG user same as
- Root DN */
- my_strncpy(mi.m_szUserGroupAdmin, mi.m_szInstanceUnrestrictedUser, sizeof(mi.m_szUserGroupAdmin));
- my_strncpy(mi.m_szUserGroupAdminPW, mi.m_szInstancePassword, sizeof(mi.m_szUserGroupAdminPW));
- }
- my_snprintf(mi.m_szUserGroupURL, sizeof(mi.m_szUserGroupURL), "ldap://%s:%d/%s", mi.m_szInstanceHostName,
- mi.m_nInstanceServerPort, mi.m_szInstanceSuffix);
- }
- SetLdapUserDirInit(TRUE);
- utf8UserGroupAdmin = localToUTF8(mi.m_szUserGroupAdmin);
- utf8UserGroupAdminPW = localToUTF8(mi.m_szUserGroupAdminPW);
- utf8UserGroupURL = localToUTF8(mi.m_szUserGroupURL);
- SetLdapUserDirID(utf8UserGroupAdmin);
- SetLdapUserDirPWD(utf8UserGroupAdminPW);
- SetLdapUserDirURL(utf8UserGroupURL);
- nsSetupFree(utf8UserGroupAdmin);
- nsSetupFree(utf8UserGroupAdminPW);
- nsSetupFree(utf8UserGroupURL);
- }
- /* converts server ID of the form slapd-foo to foo, and NULL to "" */
- static const char *
- getShortName(const char *serverID)
- {
- const char *retval = serverID;
- const char *prefix = "slapd-";
- int preflen = strlen(prefix);
- if (serverID && !strncmp(serverID, prefix, preflen))
- retval = serverID + preflen;
- if (!retval)
- retval = "";
- return retval;
- }
- static FILE*
- getLogFileP()
- {
- static FILE* logfp = 0;
- if (!getenv("USE_LOGFILE"))
- return logfp;
- if (!logfp)
- logfp = fopen("c:\\debug.out", "w");
- return logfp;
- }
- static void
- myLogData(const char *s, ...)
- {
- FILE* logfp = getLogFileP();
- va_list ap;
- if (!logfp)
- return;
- va_start(ap, s);
- vfprintf(logfp, s, ap);
- va_end(ap);
- fprintf(logfp, "\n");
- fflush(logfp);
- }
- /* Will return a malloc'd "" if no error - so caller should always use LocalFree() with
- the returned value
- */
- static LPVOID
- getLastErrorMessage()
- {
- LPVOID lpMsgBuf = NULL;
- FormatMessage(
- FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
- NULL,
- GetLastError(),
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
- (LPTSTR) &lpMsgBuf,
- 0,
- NULL);
- /* always return something . . . */
- if (lpMsgBuf == NULL) {
- lpMsgBuf = strdup("");
- }
- return lpMsgBuf;
- }
- static void
- myLogError(const char *s, ...)
- {
- va_list ap;
- LPVOID lpMsgBuf;
- FILE* logfp = getLogFileP();
- if (!logfp)
- return;
- if (lpMsgBuf = getLastErrorMessage()) {
- fprintf(logfp, "Error: %d (%s): at ", GetLastError(), lpMsgBuf);
- // Free the buffer.
- LocalFree( lpMsgBuf );
- }
- va_start(ap, s);
- vfprintf(logfp, s, ap);
- va_end(ap);
- }
- /*
- prints a message if the given dn uses LDAPv2 style quoting
- */
- void
- checkForLDAPv2Quoting(const char *dn_to_test)
- {
- char *utf8dn = localToUTF8(dn_to_test);
- if (ds_dn_uses_LDAPv2_quoting(utf8dn))
- {
- char *newdn = strdup(dn_to_test);
- fixDN(newdn);
- DSMessageBoxOK(WARN_USING_LDAPV2_QUOTES_TITLE,
- WARN_USING_LDAPV2_QUOTES,
- dn_to_test, dn_to_test, newdn);
- free(newdn);
- }
- if (utf8dn)
- nsSetupFree(utf8dn);
- return;
- }
- int
- IsValidAdminDomain(
- const char *host,
- int port,
- const char *suffix,
- const char *admin_domain,
- const char *binddn,
- const char *binddnpwd
- )
- {
- char ldapurl[4096];
- int status = FALSE;
- Ldap *ldap = NULL;
- my_snprintf(ldapurl, sizeof(ldapurl), "ldap://%s:%d/%s", host, port, suffix);
- if (createLdap(&ldap, ldapurl, binddn, binddnpwd, 0, 0) == OKAY)
- {
- LdapEntry *le = createLdapEntry(ldap);
- char *dn = formAdminDomainDN(admin_domain);
- if (le && dn && entryExists(le, dn))
- status = TRUE;
- if (dn)
- nsSetupFree(dn);
- if (le)
- destroyLdapEntry(le);
- }
- if (ldap)
- destroyLdap(ldap);
- return status;
- }
- void ControlSlapdInstance(char *pszServiceName, BOOL bOn);
- static void ConvertPasswordToPin(char *pszServerRoot, char *pszServiceName);
- static void ReinstallUpgradeServer(char *pszServerRoot, char *pszServiceName);
- char *getGMT()
- {
- static char buf[20];
- time_t curtime;
- struct tm ltm;
- curtime = time( (time_t *)0 );
- #ifdef _WIN32
- ltm = *gmtime( &curtime );
- #else
- gmtime_r( &curtime, <m );
- #endif
- strftime( buf, sizeof(buf), "%Y%m%d%H%M%SZ", <m );
- return buf;
- }
- char *onezero2yesno(int value)
- {
- if (1 == value)
- {
- return "yes";
- }else{
- return "no";
- }
- }
- int yesno2onezero(char *value)
- {
- if(!lstrcmpi("yes", value) )
- {
- return 1;
- }else{
- return 0;
- }
- }
- ////////////////
- ///
- // determine whether a string contains 8 bit characters
- //
- static int
- contains8BitChars(const char *s)
- {
- int ret = 0;
- if (s && *s)
- {
- for (; !ret && *s; ++s)
- {
- ret = (*s & 0x80);
- }
- }
- return ret;
- }
- ////////////////
- ///
- // determine whether a dn is valid or not
- //
- static int
- isAValidDN(const char *dn_to_test)
- {
- int ret = 1;
- if (!dn_to_test || !*dn_to_test)
- {
- ret = 0;
- }
- else
- {
- char *utf8dn = localToUTF8(dn_to_test);
- char **rdnList = ldap_explode_dn(utf8dn, 0);
- char **rdnNoTypes = ldap_explode_dn(utf8dn, 1);
- if (!rdnList || !rdnList[0] || !rdnNoTypes || !rdnNoTypes[0] ||
- !*rdnNoTypes[0] || !stricmp(rdnList[0], rdnNoTypes[0]))
- {
- ret = 0;
- }
- if (rdnList)
- ldap_value_free(rdnList);
- if (rdnNoTypes)
- ldap_value_free(rdnNoTypes);
- if (utf8dn)
- nsSetupFree(utf8dn);
- }
- if ((ret == 1) && dn_to_test)
- checkForLDAPv2Quoting(dn_to_test);
- return ret;
- }
- ////////////////
- ///
- // check if DN is valid, display error if not
- // returns 1 if dn is valid
- // 0 if dn is invalid
- int isValidDN(char *dn)
- {
- int nReturn;
- if( 0 == (nReturn = isAValidDN(dn)) )
- DSMessageBoxOK(ERR_INVALID_DN_TITLE, ERR_INVALID_DN, dn, dn);
- return nReturn;
- }
- ////////////////
- ///
- // check if port is valid, display error if not
- // returns 1 if port is valid
- // 0 if port is invalid
- int isValidPort(int port)
- {
- int nReturn = 1;
- if (port <= 0 || port > MAXPORT)
- {
- DSMessageBoxOK(ERR_INVALID_PORT_TITLE, ERR_INVALID_PORT, 0,
- port);
- nReturn = 0;
- }
- return nReturn;
- }
- ////////////////
- ///
- // get the components out of an ldapurl
- //
- //
- int GetURLComponents(char *szURL, char *szHost, int *nPort, char *szBase)
- {
- LDAPURLDesc *ludpp;
- int res;
- if ( ( res = ldap_url_parse( szURL, &ludpp ) ) != 0 )
- {
- return res;
- }
- if( NULL != ludpp->lud_host)
- {
- my_strncpy(szHost, ludpp->lud_host, MAX_STR_SIZE);
- }else{
- strcpy(szHost, "\0");
- }
- *nPort = ludpp->lud_port;
- if( NULL != ludpp->lud_dn)
- {
- my_strncpy(szBase, ludpp->lud_dn, MAX_STR_SIZE);
- }else{
- strcpy(szBase, "\0");
- }
- ldap_free_urldesc( ludpp );
- return 0;
- }
- ////////////////
- ///
- //
- //
- void StartWSA()
- {
- WORD wVersionRequested;
- WSADATA wsaData;
- int err;
-
- wVersionRequested = MAKEWORD( 2, 0 );
-
- err = WSAStartup( wVersionRequested, &wsaData );
- if ( err != 0 ) {
- /* Tell the user that we couldn't find a usable */
- /* WinSock DLL. */
- DSMessageBoxOK(ERR_NO_WINSOCK_TITLE, ERR_NO_WINSOCK, 0);
- return;
- }
-
- /* Confirm that the WinSock DLL supports 2.0.*/
- /* Note that if the DLL supports versions greater */
- /* than 2.0 in addition to 2.0, it will still return */
- /* 2.0 in wVersion since that is the version we */
- /* requested. */
-
- if ( LOBYTE( wsaData.wVersion ) != 2 ||
- HIBYTE( wsaData.wVersion ) != 0 ) {
- /* Tell the user that we couldn't find a usable */
- /* WinSock DLL. */
- DSMessageBoxOK(ERR_NO_WINSOCK_VER_TITLE, ERR_NO_WINSOCK_VER, 0);
- WSACleanup( );
- return;
- }
-
- /* The WinSock DLL is acceptable. Proceed. */
- }
- ////////////////
- //
- //
- //
- BOOL FullyQualifyHostName(char * HostName)
- {
- static char * domain = 0;
- struct hostent * hptr;
- BOOL bRC = TRUE;
- hptr = (struct hostent*)gethostbyname(HostName);
- if (hptr) {
- /* See if h_name is fully-qualified */
- if (hptr->h_name) {
- domain = strchr(hptr->h_name, '.');
- sprintf(HostName,"%s",hptr->h_name);
- return bRC;
- }
- /* Otherwise look for a fully qualified alias */
- if ((domain == 0) &&
- (hptr->h_aliases && hptr->h_aliases[0])) {
- char **p;
- for (p = hptr->h_aliases; *p; ++p) {
- domain = strchr(*p, '.');
- if (domain) break;
- }
- }
- }
- if (domain != 0)
- {
- if (domain[0] == '.')
- {
- ++domain;
- }
- sprintf(HostName,"%s.%s", HostName, domain);
- } else
- {
- bRC = FALSE;
- }
- return bRC;
- }
- /////////////////
- //
- // UTF8IsValidLdapUser
- //
- // converts necessary things to UTF8 before calling server
- //
- BOOL UTF8IsValidLdapUser(char *szHost, int nPort, char *szSuffix, char *szBindAs, char *szPw, BOOL bParam)
- {
- char *utf8Host=NULL;
- char *utf8Suffix=NULL;
- char *utf8BindAs=NULL;
- char *utf8Pw=NULL;
- BOOL bReturn;
-
- /* convert to UTF8 first incase international data */
- utf8Host = localToUTF8(szHost);
- utf8Suffix = localToUTF8(szSuffix);
- utf8BindAs = localToUTF8(szBindAs);
- utf8Pw = localToUTF8(szPw);
- bReturn = IsValidLdapUser(utf8Host, nPort, utf8Suffix, &utf8BindAs, utf8Pw, bParam);
- if( utf8Host) nsSetupFree(utf8Host);
- if( utf8Suffix) nsSetupFree(utf8Suffix);
- if( utf8BindAs) nsSetupFree(utf8BindAs);
- if( utf8Pw) nsSetupFree(utf8Pw);
- return bReturn;
- }
-
- /////////////////
- //
- // UTF8IsValidAdminDomain
- //
- // converts necessary things to UTF8 before calling server
- //
- BOOL UTF8IsValidAdminDomain(char *szHost, int nPort, char *szSuffix, char *szAdminDomain, char *szBindAs, char *szPw)
- {
- char *utf8Host=NULL;
- char *utf8Suffix=NULL;
- char *utf8BindAs=NULL;
- char *utf8Pw=NULL;
- char *utf8AdminDomain=NULL;
- BOOL bReturn;
-
- /* convert to UTF8 first incase international data */
- utf8Host = localToUTF8(szHost);
- utf8Suffix = localToUTF8(szSuffix);
- utf8BindAs = localToUTF8(szBindAs);
- utf8Pw = localToUTF8(szPw);
- utf8AdminDomain = localToUTF8(szAdminDomain);
- bReturn = IsValidAdminDomain(utf8Host, nPort, utf8Suffix, utf8AdminDomain, utf8BindAs, utf8Pw);
- if( utf8Host) nsSetupFree(utf8Host);
- if( utf8Suffix) nsSetupFree(utf8Suffix);
- if( utf8BindAs) nsSetupFree(utf8BindAs);
- if( utf8Pw) nsSetupFree(utf8Pw);
- if( utf8AdminDomain) nsSetupFree(utf8AdminDomain);
- return bReturn;
- }
-
- void getAdminServInfo()
- {
- char *pszAdminSection="admin";
- char szTempDir[MAX_PATH];
- char szCacheFile[MAX_PATH];
- GetEnvironmentVariable("TEMP", szTempDir, sizeof(szTempDir));
- my_snprintf(szCacheFile, sizeof(szCacheFile), "%s\\install.inf", szTempDir);
- mi.m_nAdminServerPort = GetPrivateProfileInt(pszAdminSection, SLAPD_KEY_ADMIN_SERVER_PORT,
- -1, szCacheFile);
- if (mi.m_nAdminServerPort == -1) {
- myLogData("Warning: Could not determine admin server port for Directory Server Gateway and Orgchart configuration files. Please update them manually.");
- mi.m_nAdminServerPort = DEFAULT_ADMIN_PORT;
- }
-
- }
- BOOL writeINFfile(const char *filename)
- {
- FILE *fp = fopen(filename, "wb");
-
- if (NULL == fp)
- return FALSE;
- if(0 == lstrcmp("\0", mi.m_szInstallDN) )
- {
- char * szAdminDN = NULL;
- szAdminDN = formAdminDomainDN(mi.m_szAdminDomain);
- if (szAdminDN)
- {
- my_snprintf(mi.m_szInstallDN, sizeof(mi.m_szInstallDN), szAdminDN);
- nsSetupFree(szAdminDN);
- }
- else
- {
- //note probably should fail.
- LogData(NULL, "Warning: Slapd unable to Form Admin Domain, guessing");
- my_snprintf(mi.m_szInstallDN, sizeof(mi.m_szInstallDN), "ou=%s, o=NetscapeRoot", mi.m_szAdminDomain);
- }
- }
-
- // write global section header
- fprintf(fp, "[General]\n");
- fprintf(fp, "%s= %s\n", GLOBAL_INF_LDAP_USED, "TRUE");
- fprintf(fp, "%s= %s\n", SLAPD_KEY_SERVER_ADMIN_ID, mi.m_szMCCBindAs);
- fprintf(fp, "%s= %s\n", SLAPD_KEY_SERVER_ADMIN_PWD, mi.m_szMCCPw);
- fprintf(fp, "%s= %s\n", SLAPD_KEY_FULL_MACHINE_NAME, mi.m_szInstanceHostName);
- fprintf(fp, "%s= %s\n", SLAPD_KEY_SERVER_ROOT, TARGETDIR);
-
- fprintf(fp, "%s= %s\n", SLAPD_KEY_K_LDAP_URL, mi.m_szLdapURL);
- fprintf(fp, "%s= %s\n", SLAPD_KEY_ADMIN_DOMAIN, mi.m_szAdminDomain);
- fprintf(fp, "%s= %s\n", SLAPD_KEY_USER_GROUP_LDAP_URL, mi.m_szUserGroupURL);
- fprintf(fp, "%s= %s\n", SLAPD_KEY_USER_GROUP_ADMIN_ID, mi.m_szUserGroupAdmin);
- fprintf(fp, "%s= %s\n", SLAPD_KEY_USER_GROUP_ADMIN_PWD, mi.m_szUserGroupAdminPW);
- // write Admin section header.
- getAdminServInfo(); /* Right now this only gets the admin port. If you want more,
- you'll have to change getAdminServInfo.*/
- fprintf(fp, "\n[admin]\n");
- fprintf(fp, "%s= %d\n", SLAPD_KEY_ADMIN_SERVER_PORT, mi.m_nAdminServerPort);
-
- // write DS section header
- fprintf(fp, "\n[slapd]\n");
- fprintf(fp, "%s= %d\n", SLAPD_KEY_SERVER_PORT, mi.m_nInstanceServerPort);
- if(0 == mi.m_nExistingUG)
- {
- /* don't write this key when config only directory */
- /* config only directory when using existing data store */
- fprintf(fp, "%s= %s\n", SLAPD_KEY_SUFFIX, mi.m_szInstanceSuffix);
- }
- fprintf(fp, "%s= %s\n", SLAPD_KEY_USE_EXISTING_MC,
- onezero2yesno(mi.m_nExistingMCC));
- fprintf(fp, "%s= %s\n", SLAPD_KEY_USE_EXISTING_UG,
- onezero2yesno(mi.m_nExistingUG));
- fprintf(fp, "%s= %s\n", SLAPD_KEY_ROOTDN, mi.m_szInstanceUnrestrictedUser);
- fprintf(fp, "%s= %s\n", SLAPD_KEY_ROOTDNPWD, mi.m_szInstancePassword);
- fprintf(fp, "%s= %s\n", SLAPD_KEY_SERVER_IDENTIFIER, mi.m_szServerIdentifier);
- fprintf(fp, "%s= %s\n", SLAPD_KEY_SLAPD_CONFIG_FOR_MC, onezero2yesno(mi.m_nCfgSspt) );
- fprintf(fp, "%s= %s\n", SLAPD_KEY_ADD_SAMPLE_ENTRIES, onezero2yesno(mi.m_nPopulateSampleEntries));
- fprintf(fp, "%s= %s\n", SLAPD_KEY_ADD_ORG_ENTRIES, onezero2yesno(mi.m_nPopulateSampleOrg));
- fprintf(fp, "%s= %s\n", SLAPD_KEY_USE_REPLICATION, onezero2yesno(
- (mi.m_nSetupConsumerReplication || mi.m_nSetupSupplierReplication) ));
-
- /* consumer replication settings */
- fprintf(fp, "%s= %d\n", SLAPD_KEY_SETUP_CONSUMER, mi.m_nSetupConsumerReplication);
- fprintf(fp, "%s= %s\n", SLAPD_KEY_CIR_HOST, mi.m_szConsumerHost);
- fprintf(fp, "%s= %d\n", SLAPD_KEY_CIR_PORT, mi.m_nConsumerPort);
- fprintf(fp, "%s= %s\n", SLAPD_KEY_CIR_SUFFIX, mi.m_szConsumerRoot);
- fprintf(fp, "%s= %s\n", SLAPD_KEY_CIR_BINDDN, mi.m_szConsumerBindAs);
- fprintf(fp, "%s= %s\n", SLAPD_KEY_CIR_BINDDNPWD, mi.m_szConsumerPw);
- fprintf(fp, "%s= %s\n", SLAPD_KEY_CIR_SECURITY_ON, onezero2yesno(mi.m_nConsumerSSL));
- fprintf(fp, "%s= %d\n", SLAPD_KEY_CIR_INTERVAL, mi.m_nCIRInterval);
- if(!strcmp(DEFAULT_CIR_DAYS, mi.m_szCIRDays) )
- {
- /* if default of all days write null to inf file as that is what cgi wants */
- fprintf(fp, "%s=\n", SLAPD_KEY_CIR_DAYS);
- }else{
- fprintf(fp, "%s= %s\n", SLAPD_KEY_CIR_DAYS, mi.m_szCIRDays);
- }
- if(!strcmp(DEFAULT_CIR_TIMES, mi.m_szCIRTimes) )
- {
- /* if default of all times write null to inf file as that is what cgi wants */
- fprintf(fp, "%s=\n", SLAPD_KEY_CIR_TIMES);
- }else{
- fprintf(fp, "%s= %s\n", SLAPD_KEY_CIR_TIMES, mi.m_szCIRTimes);
- }
-
- fprintf(fp, "%s= %s\n", SLAPD_KEY_REPLICATIONDN, mi.m_szSupplierDN);
- fprintf(fp, "%s= %s\n", SLAPD_KEY_REPLICATIONPWD, mi.m_szSupplierPW);
-
- /* Supplier replication settings */
- fprintf(fp, "%s= %d\n", SLAPD_KEY_SETUP_SUPPLIER, mi.m_nSetupSupplierReplication);
- fprintf(fp, "%s= %s\n", SLAPD_KEY_CHANGELOGDIR, mi.m_szChangeLogDbDir);
- fprintf(fp, "%s= %s\n", SLAPD_KEY_CHANGELOGSUFFIX, mi.m_szChangeLogSuffix);
- fprintf(fp, "%s= %s\n", SLAPD_KEY_SIR_HOST, mi.m_szSupplierHost);
- fprintf(fp, "%s= %d\n", SLAPD_KEY_SIR_PORT, mi.m_nSupplierPort);
- fprintf(fp, "%s= %s\n", SLAPD_KEY_SIR_SUFFIX, mi.m_szSupplierRoot);
- fprintf(fp, "%s= %s\n", SLAPD_KEY_SIR_BINDDN, mi.m_szSupplierBindAs);
- fprintf(fp, "%s= %s\n", SLAPD_KEY_SIR_BINDDNPWD, mi.m_szSupplierPw);
- fprintf(fp, "%s= %s\n", SLAPD_KEY_SIR_SECURITY_ON, onezero2yesno(mi.m_nSupplierSSL));
- if(!strcmp(DEFAULT_SIR_DAYS, mi.m_szSIRDays) )
- {
- /* if default of all days write null to inf file as that is what cgi wants */
- fprintf(fp, "%s=\n", SLAPD_KEY_SIR_DAYS);
- }else{
- fprintf(fp, "%s= %s\n", SLAPD_KEY_SIR_DAYS, mi.m_szSIRDays);
- }
- if(!strcmp(DEFAULT_SIR_TIMES, mi.m_szSIRTimes) )
- {
- /* if default of all times write null to inf file as that is what cgi wants */
- fprintf(fp, "%s=\n", SLAPD_KEY_SIR_TIMES);
- }else{
- fprintf(fp, "%s= %s\n", SLAPD_KEY_SIR_TIMES, mi.m_szSIRTimes);
- }
- fprintf(fp, "%s= %s\n", LOCAL_INF_CONFIG_CONSUMER_DN, onezero2yesno(mi.m_nConfigConsumerDN));
- fprintf(fp, "%s= %s\n", SLAPD_KEY_CONSUMERDN, mi.m_szConsumerDN);
- fprintf(fp, "%s= %s\n", SLAPD_KEY_CONSUMERPWD, mi.m_szConsumerPW);
-
-
- fprintf(fp, "%s= %s\n", SLAPD_KEY_INSTALL_LDIF_FILE, mi.m_szPopLdifFile);
- fprintf(fp, "%s= %s\n", SLAPD_KEY_DISABLE_SCHEMA_CHECKING, onezero2yesno(mi.m_nDisableSchemaChecking));
- fprintf(fp, "%s= %d\n", LOCAL_INF_SNMP_ON, mi.m_nSNMPOn);
- fprintf(fp, "%s= %s\n", SLAPD_INSTALL_LOG_FILE_NAME, LOGFILE );
- fclose(fp);
- return TRUE;
- }
- //////////////////////////////////////////////////////////////////////////////
- // isValidServerID(char *pszServerIdentifier)
- //
- // check if valid serverid, for n
- //
- BOOL isValidServerID(char *pszServerIdentifier)
- {
- char *fullId;
- char line[MAX_PATH];
- DWORD Result;
- HKEY hServerKey;
- BOOL bRC = TRUE;
- /* first check that it only contains 7 bit characters */
- if( contains8BitChars(pszServerIdentifier) )
- {
- DSMessageBoxOK(ERR_8BIT_SERVID_TITLE, ERR_8BIT_SERVID, 0);
- bRC = FALSE;
- }else{
- /* looks ok, now check if it already exists */
- /* for now just check registry to see if this server ID exists,
- in future add might want to add more sanity checks */
- size_t len = strlen(DS_ID_SERVICE) + strlen(pszServerIdentifier) + 2;
- fullId = malloc(len);
- sprintf(fullId, "%s-%s", DS_ID_SERVICE, pszServerIdentifier);
- my_snprintf(line, sizeof(line), "%s\\%s", KEY_SERVICES, fullId);
-
- Result = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
- line,
- 0,
- KEY_ALL_ACCESS,
- &hServerKey);
- if (Result == ERROR_SUCCESS)
- {
- /* it already exists */
- DSMessageBoxOK(ERR_SERVER_ID_EXISTS_TITLE, ERR_SERVER_ID_EXISTS,
- getShortName(pszServerIdentifier),
- getShortName(pszServerIdentifier));
- bRC = FALSE;
- }
- free(fullId);
- }
- return bRC;
- }
- //////////////////////////////////////////////////////////////////////////////
- //
- // set_default_ldap_settings()
- //
- // hostname = getHostName
- // serverid = hostname up to first period
- // suffix = o=(rest of hostname) ie o=mcom.com
- // port = 389
- // rootDn = DirectoryManager
- int set_default_ldap_settings()
- {
- int i, j = 0;
- DSGetHostName(mi.m_szInstanceHostName, MAX_STR_SIZE);
- /* assumption: hostname up to first period for serverid */
- for( i = 0; !( (mi.m_szInstanceHostName[i] == '\0')
- || (mi.m_szInstanceHostName[i] == '.' ) );
- i++)
- {
- mi.m_szServerIdentifier[i] = mi.m_szInstanceHostName[i];
- }
- /* null terminate it */
- mi.m_szServerIdentifier[i]='\0';
- if (mi.m_szInstanceHostName[0] && strchr(mi.m_szInstanceHostName, '.'))
- {
- DSGetDefaultSuffix(mi.m_szInstanceSuffix, mi.m_szInstanceHostName);
- }
- else
- {
- strcpy(mi.m_szInstanceSuffix, "dc=example, dc=com");
- }
- /* default admin domain is also derived from the FQDN */
- ++i;
- my_snprintf(mi.m_szAdminDomain, sizeof(mi.m_szAdminDomain), "%s", mi.m_szInstanceHostName+i);
-
- mi.m_nInstanceServerPort=DEFAULT_SERVER_PORT;
-
- my_snprintf(mi.m_szInstanceUnrestrictedUser, sizeof(mi.m_szInstanceUnrestrictedUser), DEFAULT_UNRESTRICTED_USER);
- mi.m_nCfgSspt = DEFAULT_CONFIG_SSPT;
- my_snprintf(mi.m_szSsptUid, sizeof(mi.m_szSsptUid), DEFAULT_SSPT_USER);
- /* stevross: don't want default for these in silent mode, user must specify them */
- if( SILENTMODE != MODE)
- {
- my_snprintf(mi.m_szSupplierDN, sizeof(mi.m_szSupplierDN), DEFAULT_SUPPLIER_DN);
- my_snprintf(mi.m_szChangeLogSuffix, sizeof(mi.m_szChangeLogSuffix), DEFAULT_CHANGELOGSUFFIX);
- }
- /* don't want to use these unless they were asked in dialog, then this flag will be
- changed */
- mi.m_nSetupSupplierReplication = NO_REPLICATION;
- mi.m_nSetupConsumerReplication = NO_REPLICATION;
- mi.m_nUseSupplierSettings = 0;
- mi.m_nUseChangeLogSettings = 0;
-
- my_strncpy(mi.m_szSIRDays, DEFAULT_SIR_DAYS, sizeof(mi.m_szSIRDays));
- my_strncpy(mi.m_szSIRTimes, DEFAULT_SIR_TIMES, sizeof(mi.m_szSIRTimes));
- mi.m_nSupplierPort = DEFAULT_SERVER_PORT;
- my_strncpy(mi.m_szCIRDays, DEFAULT_CIR_DAYS, sizeof(mi.m_szCIRDays));
- my_strncpy(mi.m_szCIRTimes, DEFAULT_CIR_TIMES, sizeof(mi.m_szCIRTimes));
- mi.m_nConsumerPort = DEFAULT_SERVER_PORT;
- mi.m_nCIRInterval = DEFAULT_CIR_INTERVAL;
-
- /* default MCC settings */
- my_strncpy(mi.m_szMCCSuffix, NS_DOMAIN_ROOT, sizeof(mi.m_szMCCSuffix));
- mi.m_nMCCPort=DEFAULT_SERVER_PORT;
- mi.m_szMCCBindAs = malloc(MAX_STR_SIZE);
- my_snprintf(mi.m_szMCCBindAs, MAX_STR_SIZE, "%s", DEFAULT_SSPT_USER);
- my_strncpy(mi.m_szUGSuffix, mi.m_szInstanceSuffix, sizeof(mi.m_szUGSuffix));
- mi.m_nUGPort=DEFAULT_SERVER_PORT;
- my_strncpy(mi.m_szUserGroupAdmin, DEFAULT_UNRESTRICTED_USER, sizeof(mi.m_szUserGroupAdmin));
- mi.m_nPopulateSampleEntries = DEFAULT_POPULATE_SAMPLE_ENTRIES;
- mi.m_nDisableSchemaChecking = DEFAULT_DISABLE_SCHEMA_CHECKING;
-
- return 0;
- }
- //////////////////////////////////////////////////////////////////////////////
- //
- // verify_ldap_settings()
- //
- // verifys that ldap settings are valid before installing instance
- //
- //
- int verify_ldap_settings()
- {
- /* XXX stevross: may want to add checks for other things later */
- /* for now just make sure port is valid */
- if( IsValidNetworkPort( mi.m_nInstanceServerPort ) )
- {
- return 0;
- }else{
- DSMessageBoxOK(ERR_SERV_RUN_ON_PORT_TITLE, ERR_SERV_RUN_ON_PORT,
- 0, mi.m_nInstanceServerPort);
- return -1;
- }
- }
- //////////////////////////////////////////////////////////////////////////////
- //
- // set_ldap_settings()
- //
- // registers ldap settings with framework for use by other installers
- //
- //
- void set_ldap_settings()
- {
-
- char *utf8MCCHost=NULL;
- char *utf8MCCSuffix=NULL;
- char *utf8MCCBindAs=NULL;
- char *utf8MCCPw=NULL;
- char *utf8AdminDomain=NULL;
- char szFullAdminDN[MAX_STR_SIZE];
- if(1 != mi.m_nExistingMCC && SILENTMODE != MODE)
- {
- /* this new instance will be MCC, but only copy over things
- if not silent mode, in silent mode it will read correct
- mcc stuff from the cache */
- my_strncpy(mi.m_szMCCHost, mi.m_szInstanceHostName, sizeof(mi.m_szMCCHost));
- mi.m_nMCCPort = mi.m_nInstanceServerPort;
- my_strncpy(mi.m_szMCCSuffix, NS_DOMAIN_ROOT, sizeof(mi.m_szMCCSuffix));
- my_snprintf(mi.m_szMCCBindAs, MAX_STR_SIZE, "%s", mi.m_szSsptUid);
- my_strncpy(mi.m_szMCCPw, mi.m_szSsptUidPw, sizeof(mi.m_szMCCPw));
- }
- /* use existing MCC stuff we read in */
- /* convert to UTF8 first for international stuff */
- utf8MCCHost = localToUTF8(mi.m_szMCCHost);
- utf8MCCSuffix = localToUTF8(mi.m_szMCCSuffix);
- utf8MCCBindAs = localToUTF8(mi.m_szMCCBindAs);
- utf8MCCPw = localToUTF8(mi.m_szMCCPw);
-
- wsprintf(szFullAdminDN, NS_ADMIN_DOMAIN, mi.m_szAdminDomain);
- utf8AdminDomain = localToUTF8(szFullAdminDN);
- SetLdapHost(utf8MCCHost);
- SetLdapPort(mi.m_nMCCPort);
- SetLdapSuffix(utf8MCCSuffix);
- SetLdapUser(utf8MCCBindAs);
- SetLdapPassword(utf8MCCPw);
- SetLdapInstallDN(utf8AdminDomain);
- if( utf8MCCHost) nsSetupFree(utf8MCCHost);
- if( utf8MCCSuffix) nsSetupFree(utf8MCCSuffix);
- if( utf8MCCBindAs) nsSetupFree(utf8MCCBindAs);
- if( utf8MCCPw) nsSetupFree(utf8MCCPw);
- if( utf8AdminDomain) nsSetupFree(utf8AdminDomain);
- }
- //////////////////////////////////////////////////////////////////////////////
- // _DialogProcs
- //
- // The dialog procedure for a single property page. You will need to create
- // one of these for each property page used in the property sheet. This
- // procedure processes dialog messages sent to your property page by Windows.
- // See the Windows SDK documentation for more information about this function.
- //
- /////////////////////////////////////////////////////////////////////////////
- // Setup8bitInputDisplay
- //
- // sets up dialog components to handle 8bit entry/display for I18n requirement
- //
- //
- //
- void Setup8bitInputDisplay(HWND hwndDlg, INT hControls[])
- {
- INT i;
- for(i=0; hControls[i] != -1; i++)
- {
- SendDlgItemMessage (hwndDlg, hControls[i], WM_SETFONT,
- (WPARAM) GetStockObject(DEFAULT_GUI_FONT) , MAKELPARAM(TRUE, 0));
- }
- }
- /////////////////////////////////////////////////////////////////////////////
- // EnableControls
- //
- // toggles editable state of Fields
- //
- //
- //
- BOOL EnableControls(INT Controls[], HWND hwndDlg, BOOL bEnable)
- {
- INT i;
- HWND hControl;
- for(i=0; Controls[i] != -1; i++)
- {
- hControl = GetDlgItem(hwndDlg, Controls[i]);
- EnableWindow(hControl, bEnable);
- }
- return TRUE;
- }
- //////////////////////////////////////////////////////////////////////////////
- // EnableLDAPURLSettingsFields
- //
- // toggles editable state of MCC Settings Fields
- //
- //
- //
- BOOL EnableLDAPURLSettingsFields(HWND hwndDlg, BOOL bEnable)
- {
- INT LDAPURL_Controls[]={IDC_EDIT_HOST,
- IDC_EDIT_PORT,
- IDC_EDIT_SUFFIX,
- IDC_EDIT_BIND_AS,
- IDC_EDIT_PW, -1};
- EnableControls(LDAPURL_Controls, hwndDlg, bEnable);
- return TRUE;
- }
- //////////////////////////////////////////////////////////////////////////////
- // EnableConsumerDNFields
- //
- // toggles editable state of Consumer DN Fields
- //
- //
- //
- BOOL EnableConsumerDNFields(HWND hwndDlg, BOOL bEnable)
- {
- INT Consumer_DN_Controls[]={IDC_EDIT_CONSUMER_DN,
- IDC_EDIT_PASSWORD,
- IDC_EDIT_PASSWORD_AGAIN,
- -1};
- EnableControls(Consumer_DN_Controls, hwndDlg, bEnable);
- return TRUE;
- }
- //////////////////////////////////////////////////////////////////////////////
- //
- // SaveDlgServerInfo
- //
- // Gets host, port, suffix, bind as, pw from dialog
- // used for MCC Settings, UG Settings, Replication Agreement Dialogs
- //
- void SaveDlgServerInfo(HWND hwndDlg,
- PSZ pszHost,
- INT *pnPort,
- PSZ pszSuffix,
- PSZ pszBindAs,
- PSZ pszPw)
- {
- BOOL bTrans;
- GetDlgItemText(hwndDlg,
- IDC_EDIT_HOST,
- pszHost,
- MAX_STR_SIZE);
- *pnPort = GetDlgItemInt(hwndDlg,
- IDC_EDIT_PORT,
- &bTrans,
- FALSE);
- GetDlgItemText(hwndDlg,
- IDC_EDIT_SUFFIX,
- pszSuffix,
- MAX_STR_SIZE);
- GetDlgItemText(hwndDlg,
- IDC_EDIT_BIND_AS,
- pszBindAs,
- MAX_STR_SIZE);
- GetDlgItemText(hwndDlg,
- IDC_EDIT_PW,
- pszPw,
- MAX_STR_SIZE);
- }
- //////////////////////////////////////////////////////////////////////////////
- //
- // LoadDlgServerInfo
- //
- // Sets host, port, suffix, bind as, pw from dialog
- // used for MCC Settings, UG Settings, Replication Agreement Dialogs
- //
- void LoadDlgServerInfo(HWND hwndDlg,
- PSZ pszHost,
- INT nPort,
- PSZ pszSuffix,
- PSZ pszBindAs,
- PSZ pszPw)
- {
- BOOL bResult;
- bResult = SetDlgItemText(hwndDlg,
- IDC_EDIT_HOST,
- pszHost);
- if(FALSE == bResult)
- {
- DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
- }
-
- bResult = SetDlgItemInt(hwndDlg,
- IDC_EDIT_PORT,
- nPort,
- TRUE);
- if(FALSE == bResult)
- {
- DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
- }
- bResult = SetDlgItemText(hwndDlg,
- IDC_EDIT_SUFFIX,
- pszSuffix);
- if(FALSE == bResult)
- {
- DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
- }
- bResult = SetDlgItemText(hwndDlg,
- IDC_EDIT_BIND_AS,
- pszBindAs);
- if(FALSE == bResult)
- {
- DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
- }
- bResult = SetDlgItemText(hwndDlg,
- IDC_EDIT_PW,
- pszPw);
- if(FALSE == bResult)
- {
- DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
- }
- }
- //////////////////////////////////////////////////////////////////////////////
- // VerifyServerInfo
- //
- // verifies Server settings are ok
- //
- // Returns TRUE if there is an invalid setting
- // Returns FALSE if all settings are valid
- //
- // SideEffect: displays error (or writes to log in silent mode)
-
- BOOL VerifyServerInfo( PSZ pszHost,
- INT *pnPort,
- PSZ pszSuffix,
- PSZ pszBindAs,
- PSZ pszPw,
- BOOL bVerifyBindAs)
- {
- BOOL bValueReturned = TRUE;
- if ( 0 == strlen( pszHost) )
- {
- DSMessageBoxOK(ERR_NO_HOST_TITLE, ERR_NO_HOST, 0);
- } else if ( 0 == *pnPort )
- {
- DSMessageBoxOK(ERR_NO_PORT_TITLE, ERR_NO_PORT, 0);
- } else if ( 0 == strlen( pszSuffix) )
- {
- DSMessageBoxOK(ERR_NO_SUFFIX_TITLE, ERR_NO_SUFFIX, 0);
- } else if ( !isValidDN(pszSuffix) )
- {
- /* error message displayed by isvalidDN */
- } else if ( 0 == strlen( pszBindAs) )
- {
- DSMessageBoxOK(ERR_NO_BIND_DN_TITLE, ERR_NO_BIND_DN, 0);
- }else if ( 0 == strlen( pszPw) )
- {
- DSMessageBoxOK(ERR_NO_PW_TITLE, ERR_NO_PW, 0);
- } else if (contains8BitChars(pszPw) )
- {
- DSMessageBoxOK(ERR_8BIT_PW_TITLE, ERR_8BIT_PW, 0);
- } else
- {
- /* all settings look good */
- bValueReturned = FALSE;
- }
- /* try to verify valid dn if need to and no
- previous invalid fields */
- if( !bValueReturned && bVerifyBindAs )
- {
- /* error message displayed by isvalidDN */
- if ( !isValidDN(pszBindAs) )
- {
- /* dn is invalid return true from here */
- bValueReturned = TRUE;
- }
- }
- return bValueReturned;
- }
- //////////////////////////////////////////////////////////////////////////////
- // SaveDialogInput_MCC_Settings
- //
- // save MCC settings entered on Dialog on back and next
- //
- //
- //
- void SaveDialogInput_MCC_Settings(HWND hwndDlg)
- {
-
- if( 1 == mi.m_nExistingMCC )
- {
- SaveDlgServerInfo(hwndDlg,
- mi.m_szMCCHost,
- &mi.m_nMCCPort,
- mi.m_szMCCSuffix,
- mi.m_szMCCBindAs,
- mi.m_szMCCPw);
- }
- }
- //////////////////////////////////////////////////////////////////////////////
- // VerifyDialogInput_MCC_Settings
- //
- // verify MCC settings entered on Dialog on back and next
- //
- //
- // Returns TRUE if there is an invalid setting
- // Returns FALSE if all settings are valid
- //
- // SideEffect: displays error (or writes to log in silent mode)
- BOOL Verify_MCC_Settings()
- {
- BOOL bValueReturned = FALSE;
- /* only check if configuring to use existing MCC */
- if (1 == mi.m_nExistingMCC)
- {
- if( FALSE == ( bValueReturned = VerifyServerInfo(mi.m_szMCCHost,
- &mi.m_nMCCPort,
- mi.m_szMCCSuffix,
- mi.m_szMCCBindAs,
- mi.m_szMCCPw,
- FALSE) ) )
- {
- /* server info ok, now check rest of the settigns */
- if (FALSE == FullyQualifyHostName(mi.m_szMCCHost) )
- {
- /* can't qualify host name, must be invalid */
- DSMessageBoxOK(ERR_INVALID_HOST_TITLE, ERR_INVALID_HOST,
- mi.m_szMCCHost, mi.m_szMCCHost);
- bValueReturned = TRUE;
- } else
- {
- /* now that all settings entered, check to see if valid user */
- if (FALSE == (UTF8IsValidLdapUser( mi.m_szMCCHost,
- mi.m_nMCCPort,
- mi.m_szMCCSuffix,
- mi.m_szMCCBindAs,
- mi.m_szMCCPw,
- FALSE) ) )
- {
- DSMessageBoxOK(ERR_CANT_FIND_DS_TITLE,
- ERR_CANT_FIND_DS, 0,
- mi.m_szMCCHost,
- mi.m_nMCCPort,
- mi.m_szMCCBindAs);
- bValueReturned = TRUE;
- }
- /* now that all settings entered, find admin domain */
- else if ((CUSTOMMODE != MODE) &&
- (FALSE == (UTF8IsValidAdminDomain( mi.m_szMCCHost,
- mi.m_nMCCPort,
- mi.m_szMCCSuffix,
- mi.m_szAdminDomain,
- mi.m_szMCCBindAs,
- mi.m_szMCCPw) ) ) )
- {
- DSMessageBoxOK(ERR_CANT_FIND_ADMIN_DOMAIN_TITLE,
- ERR_CANT_FIND_ADMIN_DOMAIN, mi.m_szAdminDomain,
- mi.m_szAdminDomain,
- mi.m_szMCCHost,
- mi.m_nMCCPort,
- mi.m_szMCCBindAs);
- bValueReturned = TRUE;
- }
- /* all settings good */
- /* don't want to cfg sspt if already have mcc user */
- mi.m_nCfgSspt = 0;
- }
- }
- }
- return bValueReturned;
- }
- //////////////////////////////////////////////////////////////////////////////
- // MCC_Settings_DialogProc
- //
- // dialog proc to choose MCC server settings
- //
- //
- //
- static BOOL CALLBACK
- MCC_Settings_DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
- {
- BOOL bValueReturned = FALSE;
- UINT uResult = 0;
- BOOL bResult = FALSE;
- /* list of controls to be setup for 8bit input/display */
- INT h8bitControls[]={IDC_EDIT_HOST,
- IDC_EDIT_SUFFIX,
- IDC_EDIT_BIND_AS,
- IDC_EDIT_PW, -1};
- switch (uMsg)
- {
- case WM_INITDIALOG:
- // This message is sent when the property page is first created. Here
- // you can perform any one time initialization that you require.
- Setup8bitInputDisplay(hwndDlg, h8bitControls);
- ShowWindow(GetDlgItem(hwndDlg, IDC_EDIT_SUFFIX), FALSE);
- ShowWindow(GetDlgItem(hwndDlg, IDC_STATIC_MCC_SUFFIX), FALSE);
- break;
- case WM_COMMAND:
- // Windows sends WM_COMMAND messages whenever the user clicks on
- // a control in your property page. If you need to perform some
- // special action, such as validating data or responding to a
- // button click, do it here.
-
- if(BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_RADIO_USE_EXISTING_SERVER) )
- {
- EnableLDAPURLSettingsFields(hwndDlg, TRUE);
- mi.m_nExistingMCC = 1;
- }else if(BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_RADIO_USE_THIS_SERVER) ){
- EnableLDAPURLSettingsFields(hwndDlg, FALSE);
- mi.m_nExistingMCC = 0;
- }
- break;
- case WM_NOTIFY:
- // Windows sends WM_NOTIFY messages to your property page whenever
- // something interesting happens to the page. This could be page
- // activation/deactivation, a button click, etc. The wParam parameter
- // contains a pointer to the property page. The lParam parameter
- // contains a pointer to an NMHDR structure. The code field of this
- // structure contains the notification message code being sent. The
- // property sheet API allows you to alter the behavior of these
- // messages by returning a value for each message. To return a value,
- // use the SetWindowLong Windows SDK function.
- switch (((NMHDR*)lParam)->code)
- {
- case PSN_SETACTIVE:
- // This notification is sent upon activation of the property page.
- // The property sheet should be centered each time it is activated
- // in case the user has moved the stupid thing (this duplicates
- // InstallShield functionality). You should also set the state of
- // the wizard buttons here.
- //
- // NOTE: If you do not wish this page to become active, return -1.
- LoadDlgServerInfo(hwndDlg,
- mi.m_szMCCHost,
- mi.m_nMCCPort,
- mi.m_szMCCSuffix,
- mi.m_szMCCBindAs,
- mi.m_szMCCPw);
-
- CheckRadioButton(hwndDlg, IDC_RADIO_USE_THIS_SERVER,
- IDC_RADIO_USE_EXISTING_SERVER,
- ( (1 == mi.m_nExistingMCC) ? IDC_RADIO_USE_EXISTING_SERVER :
- IDC_RADIO_USE_THIS_SERVER));
- if(1 == mi.m_nExistingMCC)
- {
- EnableLDAPURLSettingsFields(hwndDlg, TRUE);
- }else{
- EnableLDAPURLSettingsFields(hwndDlg, FALSE);
- }
- CenterWindow(GetParent(hwndDlg));
- PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
- break;
- case PSN_KILLACTIVE:
- // This notification is sent upon deactivation of the property page.
- // Here you can do whatever might be necessary for this action, such
- // as saving the state of the controls. You should also reset the
- // the state of the wizard buttons here, as both the Back and Next
- // buttons should be active when you leave the AskOptions function.
- //
- // NOTE: If you do not want the page deactivated, return -1.
- PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
- break;
- case PSN_WIZBACK:
- // The user clicked the back button from the first property page.
- // Set the result code NS_WIZBACK to indicate this action and close
- // the property sheet using brute force. If this procedure is not
- // being used by the first property sheet, you should ignore this
- // notification and simply let windows go to the previous page.
- //
- // NOTE: To prevent the wizard from stepping back, return -1.
- SaveDialogInput_MCC_Settings(hwndDlg);
-
- /* first dialog, so send wizback to previous module */
- mi.m_nResult = NS_WIZBACK;
- SendMessage(GetParent(hwndDlg), WM_CLOSE, 0, 0);
- break;
- case PSN_WIZNEXT:
- // The user clicked the next button from the last property page.
- // Set the result code NS_WIZNEXT to indicate this action and close
- // the property sheet using brute force. If this procedure is not
- // being used by the last property sheet, you should ignore this
- // notification and simply let windows go to the next page.
- //
- // NOTE: To prevent the wizard from stepping ahead, return -1.
- SaveDialogInput_MCC_Settings(hwndDlg);
- if( TRUE == (bValueReturned = Verify_MCC_Settings() ) )
- {
- // one of the settings was invalid so stay on this page
- SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
- }
- break;
- case PSN_QUERYCANCEL:
- // This notification is sent when the user clicks the Cancel button.
- // It is also sent in response to the WM_CLOSE messages issued
- // by PSN_WIZBACK and PSN_WIZNEXT. Make sure that we only process
- // this message if the result is not back or next so that we don't
- // nuke the return value assigned by PSN_WIZBACK or PSN_WIZNEXT.
- //
- // NOTE: To prevent the cancel from occuring, return -1.
- if (mi.m_nResult != NS_WIZBACK && mi.m_nResult != NS_WIZNEXT)
- {
- if (QueryExit(hwndDlg))
- {
- mi.m_nResult = NS_WIZCANCEL;
- }
- else
- {
- SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
- bValueReturned = TRUE;
- }
- }
- break;
- }
- break;
- }
- return bValueReturned;
- }
- //////////////////////////////////////////////////////////////////////////////
- //
- // SaveDialogInput_ReInstall
- //
- // saves settings entered in ReInstall Dlg
- //
- void SaveDialogInput_ReInstall(HWND hwndDlg)
- {
- GetDlgItemText(hwndDlg,
- IDC_EDIT_BIND_AS,
- mi.m_szMCCBindAs,
- MAX_STR_SIZE);
- GetDlgItemText(hwndDlg,
- IDC_EDIT_PW,
- mi.m_szMCCPw,
- MAX_STR_SIZE);
- }
- //////////////////////////////////////////////////////////////////////////////
- // Verify_ReInstall
- //
- // verify ReInstall settings entered on Dialog on back and next
- //
- //
- // Returns TRUE if there is an invalid setting
- // Returns FALSE if all settings are valid
- //
- // SideEffect: displays error (or writes to log in silent mode)
- BOOL Verify_ReInstall()
- {
- BOOL bValueReturned = FALSE;
- /* Get URL components so we can verify all MCC settings */
- if( GetURLComponents(mi.m_szLdapURL, mi.m_szMCCHost,
- &mi.m_nMCCPort, mi.m_szMCCSuffix) != 0)
- {
- /* error Getting URL Components*/
- DSMessageBoxOK(ERR_NO_CONFIG_URL_TITLE, ERR_NO_CONFIG_URL, 0);
- bValueReturned = TRUE;
- }else{
- /* since we have all MCC info,
- pass it thorugh Verify_MCC_Settings
- to do all the same verifications.*/
- /* set this to one so MCC Settings get checked */
- mi.m_nExistingMCC = 1;
- bValueReturned = Verify_MCC_Settings();
- }
- return bValueReturned;
- }
- //////////////////////////////////////////////////////////////////////////////
- // ReInstall Dialog Proc
- //
- // ask configuration information needed on reinstall
- //
- //
- //
- //
- static BOOL CALLBACK
- ReInstall_DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
- {
- BOOL bValueReturned = FALSE;
- UINT uResult = 0;
- BOOL bResult = FALSE;
-
- /* list of controls to be setup for 8bit input/display */
- INT h8bitControls[]={IDC_EDIT_BIND_AS,
- -1};
-
- switch (uMsg)
- {
- case WM_INITDIALOG:
- // This message is sent when the property page is first created. Here
- // you can perform any one time initialization that you require.
- Setup8bitInputDisplay(hwndDlg, h8bitControls);
- break;
- case WM_COMMAND:
- // Windows sends WM_COMMAND messages whenever the user clicks on
- // a control in your property page. If you need to perform some
- // special action, such as validating data or responding to a
- // button click, do it here.
-
- break;
- case WM_NOTIFY:
- // Windows sends WM_NOTIFY messages to your property page whenever
- // something interesting happens to the page. This could be page
- // activation/deactivation, a button click, etc. The wParam parameter
- // contains a pointer to the property page. The lParam parameter
- // contains a pointer to an NMHDR structure. The code field of this
- // structure contains the notification message code being sent. The
- // property sheet API allows you to alter the behavior of these
- // messages by returning a value for each message. To return a value,
- // use the SetWindowLong Windows SDK function.
- switch (((NMHDR*)lParam)->code)
- {
- char * szLdapUrl;
- case PSN_SETACTIVE:
-
- // This notification is sent upon activation of the property page.
- // The property sheet should be centered each time it is activated
- // in case the user has moved the stupid thing (this duplicates
- // InstallShield functionality). You should also set the state of
- // the wizard buttons here.
- //
- // NOTE: If you do not wish this page to become active, return -1.
- /* This dialog is displayed in the following ways */
- /* Creating MCC Custom & normal mode ( after MCC admin page) */
- /* or */
- /* Using existing MCC Custom Mode Only (after MCC Settings Page ) */
-
- szLdapUrl = stripConfigLdapURL(mi.m_szLdapURL);
- bResult = SetDlgItemText(hwndDlg,
- IDC_CONFIG_URL_VAL,
- szLdapUrl);
- if(FALSE == bResult)
- {
- DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
- }
- bResult = SetDlgItemText(hwndDlg,
- IDC_EDIT_BIND_AS,
- mi.m_szMCCBindAs);
- if(FALSE == bResult)
- {
- DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
- }
- bResult = SetDlgItemText(hwndDlg,
- IDC_EDIT_PW,
- mi.m_szMCCPw);
- if(FALSE == bResult)
- {
- DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
- }
-
- CenterWindow(GetParent(hwndDlg));
- PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
- break;
- case PSN_KILLACTIVE:
- // This notification is sent upon deactivation of the property page.
- // Here you can do whatever might be necessary for this action, such
- // as saving the state of the controls. You should also reset the
- // the state of the wizard buttons here, as both the Back and Next
- // buttons should be active when you leave the AskOptions function.
- //
- // NOTE: If you do not want the page deactivated, return -1.
- PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
- break;
- case PSN_WIZBACK:
- // The user clicked the back button from the first property page.
- // Set the result code NS_WIZBACK to indicate this action and close
- // the property sheet using brute force. If this procedure is not
- // being used by the first property sheet, you should ignore this
- // notification and simply let windows go to the previous page.
- //
- // NOTE: To prevent the wizard from stepping back, return -1.
-
- SaveDialogInput_ReInstall(hwndDlg);
-
- // this is only dialog, so set back to go to other module */
- mi.m_nResult = NS_WIZBACK;
- SendMessage(GetParent(hwndDlg), WM_CLOSE, 0, 0);
-
- break;
- case PSN_WIZNEXT:
- // The user clicked the next button from the last property page.
- // Set the result code NS_WIZNEXT to indicate this action and close
- // the property sheet using brute force. If this procedure is not
- // being used by the last property sheet, you should ignore this
- // notification and simply let windows go to the next page.
- //
- // NOTE: To prevent the wizard from stepping ahead, return -1.
-
- SaveDialogInput_ReInstall(hwndDlg);
- if (TRUE == (bValueReturned = Verify_ReInstall() ) )
- {
- /* setting is invalid stay on this page */
- SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
- }else{
- /* everything looks ok */
-
- // this is only dialog, so set back to go to other module */
- mi.m_nResult = NS_WIZNEXT;
- SendMessage(GetParent(hwndDlg), WM_CLOSE, 0, 0);
- }
- break;
- case PSN_QUERYCANCEL:
- // This notification is sent when the user clicks the Cancel button.
- // It is also sent in response to the WM_CLOSE messages issued
- // by PSN_WIZBACK and PSN_WIZNEXT. Make sure that we only process
- // this message if the result is not back or next so that we don't
- // nuke the return value assigned by PSN_WIZBACK or PSN_WIZNEXT.
- //
- // NOTE: To prevent the cancel from occuring, return -1.
- if (mi.m_nResult != NS_WIZBACK && mi.m_nResult != NS_WIZNEXT)
- {
- if (QueryExit(hwndDlg))
- {
- mi.m_nResult = NS_WIZCANCEL;
- }
- else
- {
- SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
- bValueReturned = TRUE;
- }
- }
- break;
- }
- break;
- }
- return bValueReturned;
- }
- //////////////////////////////////////////////////////////////////////////////
- //
- // SaveDialogInput_AdminDomain
- //
- //
- // save settings entered in admin domain dialog proc
- //
- //
- void SaveDialogInput_AdminDomain(HWND hwndDlg)
- {
- GetDlgItemText(hwndDlg,
- IDC_EDIT_ADMIN_DOMAIN,
- mi.m_szAdminDomain,
- MAX_STR_SIZE);
- }
- //////////////////////////////////////////////////////////////////////////////
- //
- // Verify_AdminDomain
- //
- //
- // verify and save settings entered in admin domain dialog proc
- //
- // Returns TRUE if there is an invalid setting
- // Returns False if all settings are valid
- //
- // SideEffect: displays error (or writes to log in silent mode)
- BOOL VerifyAdminDomain()
- {
- BOOL bValueReturned = TRUE;
- if(0 == strlen(mi.m_szAdminDomain) )
- {
- DSMessageBoxOK(ERR_NO_ADMIN_DOMAIN_TITLE, ERR_NO_ADMIN_DOMAIN, 0);
- }else if(isAValidDN(mi.m_szAdminDomain) ){
- /* admin domain is not allowed to be a DN, so if it is
- prompt user and return error */
- DSMessageBoxOK(ERR_ADMIN_DOMAIN_DN_TITLE, ERR_ADMIN_DOMAIN_DN,
- mi.m_szAdminDomain, mi.m_szAdminDomain);
- }else if (0 == mi.m_nExistingMCC){
- /* we are creating the Config Directory, so we don't need to check if
- the admin domain is present */
- bValueReturned = FALSE;
- /* now that all settings entered, find admin domain */
- }else if (FALSE == (UTF8IsValidAdminDomain( mi.m_szMCCHost,
- mi.m_nMCCPort,
- mi.m_szMCCSuffix,
- mi.m_szAdminDomain,
- mi.m_szMCCBindAs,
- mi.m_szMCCPw) ) )
- {
- DSMessageBoxOK(ERR_CANT_FIND_ADMIN_DOMAIN_TITLE,
- ERR_CANT_FIND_ADMIN_DOMAIN, mi.m_szAdminDomain,
- mi.m_szAdminDomain,
- mi.m_szMCCHost,
- mi.m_nMCCPort,
- mi.m_szMCCBindAs);
- bValueReturned = TRUE;
- }else{
- /* all settings ok, return false */
- bValueReturned = FALSE;
- }
- return bValueReturned;
- }
- //////////////////////////////////////////////////////////////////////////////
- // Admin Domain Dialog Proc
- //
- // dialog proc to ask for admin domain
- //
- //
- //
- //
- static BOOL CALLBACK
- AdminDomain_DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
- {
- BOOL bValueReturned = FALSE;
- UINT uResult = 0;
- BOOL bResult = FALSE;
-
- /* list of controls to be setup for 8bit input/display */
- INT h8bitControls[]={IDC_EDIT_ADMIN_DOMAIN
- -1};
- switch (uMsg)
- {
- case WM_INITDIALOG:
- // This message is sent when the property page is first created. Here
- // you can perform any one time initialization that you require.
- Setup8bitInputDisplay(hwndDlg, h8bitControls);
- break;
- case WM_COMMAND:
- // Windows sends WM_COMMAND messages whenever the user clicks on
- // a control in your property page. If you need to perform some
- // special action, such as validating data or responding to a
- // button click, do it here.
-
- break;
- case WM_NOTIFY:
- // Windows sends WM_NOTIFY messages to your property page whenever
- // something interesting happens to the page. This could be page
- // activation/deactivation, a button click, etc. The wParam parameter
- // contains a pointer to the property page. The lParam parameter
- // contains a pointer to an NMHDR structure. The code field of this
- // structure contains the notification message code being sent. The
- // property sheet API allows you to alter the behavior of these
- // messages by returning a value for each message. To return a value,
- // use the SetWindowLong Windows SDK function.
- switch (((NMHDR*)lParam)->code)
- {
- case PSN_SETACTIVE:
- // This notification is sent upon activation of the property page.
- // The property sheet should be centered each time it is activated
- // in case the user has moved the stupid thing (this duplicates
- // InstallShield functionality). You should also set the state of
- // the wizard buttons here.
- //
- // NOTE: If you do not wish this page to become active, return -1.
- /* This dialog is displayed in the following ways */
- /* Creating MCC Custom & normal mode ( after MCC admin page) */
- /* or */
- /* Using existing MCC Custom Mode Only (after MCC Settings Page ) */
-
- if(1 == mi.m_nExistingMCC )
- {
- /* not creating an MCC so don't ask this page */
- SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
- return TRUE;
- }
-
- bResult = SetDlgItemText(hwndDlg,
- IDC_EDIT_ADMIN_DOMAIN,
- mi.m_szAdminDomain);
- if(FALSE == bResult)
- {
- DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
- }
- CenterWindow(GetParent(hwndDlg));
- PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
- break;
- case PSN_KILLACTIVE:
- // This notification is sent upon deactivation of the property page.
- // Here you can do whatever might be necessary for this action, such
- // as saving the state of the controls. You should also reset the
- // the state of the wizard buttons here, as both the Back and Next
- // buttons should be active when you leave the AskOptions function.
- //
- // NOTE: If you do not want the page deactivated, return -1.
- PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
- break;
- case PSN_WIZBACK:
- // The user clicked the back button from the first property page.
- // Set the result code NS_WIZBACK to indicate this action and close
- // the property sheet using brute force. If this procedure is not
- // being used by the first property sheet, you should ignore this
- // notification and simply let windows go to the previous page.
- //
- // NOTE: To prevent the wizard from stepping back, return -1.
- SaveDialogInput_AdminDomain(hwndDlg);
- break;
- case PSN_WIZNEXT:
- // The user clicked the next button from the last property page.
- // Set the result code NS_WIZNEXT to indicate this action and close
- // the property sheet using brute force. If this procedure is not
- // being used by the last property sheet, you should ignore this
- // notification and simply let windows go to the next page.
- //
- // NOTE: To prevent the wizard from stepping ahead, return -1.
- SaveDialogInput_AdminDomain(hwndDlg);
- if (TRUE == (bValueReturned = VerifyAdminDomain() ) )
- {
- /* setting is invalid stay on this page */
- SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
- }
- break;
- case PSN_QUERYCANCEL:
- // This notification is sent when the user clicks the Cancel button.
- // It is also sent in response to the WM_CLOSE messages issued
- // by PSN_WIZBACK and PSN_WIZNEXT. Make sure that we only process
- // this message if the result is not back or next so that we don't
- // nuke the return value assigned by PSN_WIZBACK or PSN_WIZNEXT.
- //
- // NOTE: To prevent the cancel from occuring, return -1.
- if (mi.m_nResult != NS_WIZBACK && mi.m_nResult != NS_WIZNEXT)
- {
- if (QueryExit(hwndDlg))
- {
- mi.m_nResult = NS_WIZCANCEL;
- }
- else
- {
- SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
- bValueReturned = TRUE;
- }
- }
- break;
- }
- break;
- }
- return bValueReturned;
- }
- //////////////////////////////////////////////////////////////////////////////
- // Admin Domain Custom Dialog Proc
- //
- // dialog proc to ask for admin domain in custom mode when we are installing
- // into existing MCC
- //
- // basically the same as Admin Domain with some added code to lookup domain
- // kind of lame to duplicate code, but this was the best way to get flow to match unix
- //
- static BOOL CALLBACK
- AdminDomainCustom_DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
- {
- BOOL bValueReturned = FALSE;
- UINT uResult = 0;
- BOOL bResult = FALSE;
-
- /* list of controls to be setup for 8bit input/display */
- INT h8bitControls[]={IDC_EDIT_ADMIN_DOMAIN
- -1};
- switch (uMsg)
- {
- case WM_INITDIALOG:
- // This message is sent when the property page is first created. Here
- // you can perform any one time initialization that you require.
- Setup8bitInputDisplay(hwndDlg, h8bitControls);
- break;
- case WM_COMMAND:
- // Windows sends WM_COMMAND messages whenever the user clicks on
- // a control in your property page. If you need to perform some
- // special action, such as validating data or responding to a
- // button click, do it here.
-
- break;
- case WM_NOTIFY:
- // Windows sends WM_NOTIFY messages to your property page whenever
- // something interesting happens to the page. This could be page
- // activation/deactivation, a button click, etc. The wParam parameter
- // contains a pointer to the property page. The lParam parameter
- // contains a pointer to an NMHDR structure. The code field of this
- // structure contains the notification message code being sent. The
- // property sheet API allows you to alter the behavior of these
- // messages by returning a value for each message. To return a value,
- // use the SetWindowLong Windows SDK function.
- switch (((NMHDR*)lParam)->code)
- {
- case PSN_SETACTIVE:
- // This notification is sent upon activation of the property page.
- // The property sheet should be centered each time it is activated
- // in case the user has moved the stupid thing (this duplicates
- // InstallShield functionality). You should also set the state of
- // the wizard buttons here.
- //
- // NOTE: If you do not wish this page to become active, return -1.
- /* This dialog is displayed in the following ways */
- /* Creating MCC Custom & normal mode ( after MCC admin page) */
- /* or */
- /* Using existing MCC Custom Mode Only (after MCC Settings Page ) */
-
- /* only display this page in Custom Mode if installing into existing MCC */
- if( (0 == mi.m_nExistingMCC) || CUSTOMMODE != MODE)
- {
- /* dont display this page */
- SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
- return TRUE;
- }
-
- /* since we are installing into existing mcc we can search it for admin domains */
-
- /* stevross: add code to search for admin domains here */
-
- bResult = SetDlgItemText(hwndDlg,
- IDC_EDIT_ADMIN_DOMAIN,
- mi.m_szAdminDomain);
- if(FALSE == bResult)
- {
- DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
- }
- CenterWindow(GetParent(hwndDlg));
- PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
- break;
- case PSN_KILLACTIVE:
- // This notification is sent upon deactivation of the property page.
- // Here you can do whatever might be necessary for this action, such
- // as saving the state of the controls. You should also reset the
- // the state of the wizard buttons here, as both the Back and Next
- // buttons should be active when you leave the AskOptions function.
- //
- // NOTE: If you do not want the page deactivated, return -1.
- PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
- break;
- case PSN_WIZBACK:
- // The user clicked the back button from the first property page.
- // Set the result code NS_WIZBACK to indicate this action and close
- // the property sheet using brute force. If this procedure is not
- // being used by the first property sheet, you should ignore this
- // notification and simply let windows go to the previous page.
- //
- // NOTE: To prevent the wizard from stepping back, return -1.
- SaveDialogInput_AdminDomain(hwndDlg);
- break;
- case PSN_WIZNEXT:
- // The user clicked the next button from the last property page.
- // Set the result code NS_WIZNEXT to indicate this action and close
- // the property sheet using brute force. If this procedure is not
- // being used by the last property sheet, you should ignore this
- // notification and simply let windows go to the next page.
- //
- // NOTE: To prevent the wizard from stepping ahead, return -1.
- SaveDialogInput_AdminDomain(hwndDlg);
- if (TRUE == (bValueReturned = VerifyAdminDomain() ) )
- {
- /* setting is invalid stay on this page */
- SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
- }
- break;
- case PSN_QUERYCANCEL:
- // This notification is sent when the user clicks the Cancel button.
- // It is also sent in response to the WM_CLOSE messages issued
- // by PSN_WIZBACK and PSN_WIZNEXT. Make sure that we only process
- // this message if the result is not back or next so that we don't
- // nuke the return value assigned by PSN_WIZBACK or PSN_WIZNEXT.
- //
- // NOTE: To prevent the cancel from occuring, return -1.
- if (mi.m_nResult != NS_WIZBACK && mi.m_nResult != NS_WIZNEXT)
- {
- if (QueryExit(hwndDlg))
- {
- mi.m_nResult = NS_WIZCANCEL;
- }
- else
- {
- SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
- bValueReturned = TRUE;
- }
- }
- break;
- }
- break;
- }
- return bValueReturned;
- }
- //////////////////////////////////////////////////////////////////////////////
- //
- // SaveDialogInput_UG_Settings(HWND hwndDlg)
- //
- // Save values entered in UG dialog on back and next
- //
- //
- void SaveDialogInput_UG_Settings(HWND hwndDlg)
- {
- if (1 == mi.m_nExistingUG)
- {
- SaveDlgServerInfo(hwndDlg,
- mi.m_szUGHost,
- &mi.m_nUGPort,
- mi.m_szUGSuffix,
- mi.m_szUserGroupAdmin,
- mi.m_szUserGroupAdminPW);
- }
- }
- //////////////////////////////////////////////////////////////////////////////
- //
- // Verify_UG_Settings()
- //
- // verify values entered in UG dialog on back and next
- //
- //
- BOOL Verify_UG_Settings()
- {
- BOOL bValueReturned = FALSE;
- /* only verify if installing into existing UG */
- if (1 == mi.m_nExistingUG)
- {
- bValueReturned = VerifyServerInfo(mi.m_szUGHost,
- &mi.m_nUGPort,
- mi.m_szUGSuffix,
- mi.m_szUserGroupAdmin,
- mi.m_szUserGroupAdminPW,
- FALSE);
- if (FALSE == bValueReturned)
- {
- /* server info looks ok, now check the rest of the stuff */
- if (FALSE == FullyQualifyHostName(mi.m_szUGHost) )
- {
- /* failed to fully qualify host name */
- DSMessageBoxOK(ERR_INVALID_HOST_TITLE,
- ERR_INVALID_HOST,
- mi.m_szUGHost, mi.m_szUGHost);
- bValueReturned = TRUE;
- } else
- {
- /* now that all settings entered, check to see if valid user */
- if (FALSE == UTF8IsValidLdapUser(mi.m_szUGHost, mi.m_nUGPort,
- mi.m_szUGSuffix,
- mi.m_szUserGroupAdmin,
- mi.m_szUserGroupAdminPW,
- FALSE) )
- {
- DSMessageBoxOK(ERR_CANT_FIND_DS_TITLE,
- ERR_CANT_FIND_DS, 0, mi.m_szUGHost,
- mi.m_nUGPort, mi.m_szUserGroupAdmin);
- bValueReturned = TRUE;
- } else
- {
- /* all settings good */
- /* set UG LDAP URL */
- my_snprintf(mi.m_szUserGroupURL, sizeof(mi.m_szUserGroupURL), "ldap://%s:%d/%s",
- mi.m_szUGHost, mi.m_nUGPort, mi.m_szUGSuffix);
- }
- }
- }
- }
- return bValueReturned;
- }
- //////////////////////////////////////////////////////////////////////////////
- // UG_Settings_DialogProc
- //
- // dialog proc to choose User Group server settings
- //
- //
- //
- static BOOL CALLBACK
- UG_Settings_DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
- {
- BOOL bValueReturned = FALSE;
- UINT uResult = 0;
- BOOL bResult = FALSE;
- CHAR szTemp[MAX_STR_SIZE] = {0};
- /* list of controls to be setup for 8bit input/display */
- INT h8bitControls[]={IDC_EDIT_HOST,
- IDC_EDIT_SUFFIX,
- IDC_EDIT_BIND_AS,
- IDC_EDIT_PW, -1};
-
- switch (uMsg)
- {
- case WM_INITDIALOG:
- // This message is sent when the property page is first created. Here
- // you can perform any one time initialization that you require.
- Setup8bitInputDisplay(hwndDlg, h8bitControls);
- break;
- case WM_COMMAND:
- // Windows sends WM_COMMAND messages whenever the user clicks on
- // a control in your property page. If you need to perform some
- // special action, such as validating data or responding to a
- // button click, do it here.
-
- if(BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_RADIO_USE_EXISTING_SERVER) )
- {
- EnableLDAPURLSettingsFields(hwndDlg, TRUE);
- mi.m_nExistingUG = 1;
- }else if(BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_RADIO_USE_THIS_SERVER) ){
- EnableLDAPURLSettingsFields(hwndDlg, FALSE);
- mi.m_nExistingUG = 0;
- }
- break;
- case WM_NOTIFY:
- // Windows sends WM_NOTIFY messages to your property page whenever
- // something interesting happens to the page. This could be page
- // activation/deactivation, a button click, etc. The wParam parameter
- // contains a pointer to the property page. The lParam parameter
- // contains a pointer to an NMHDR structure. The code field of this
- // structure contains the notification message code being sent. The
- // property sheet API allows you to alter the behavior of these
- // messages by returning a value for each message. To return a value,
- // use the SetWindowLong Windows SDK function.
- switch (((NMHDR*)lParam)->code)
- {
- case PSN_SETACTIVE:
- // This notification is sent upon activation of the property page.
- // The property sheet should be centered each time it is activated
- // in case the user has moved the stupid thing (this duplicates
- // InstallShield functionality). You should also set the state of
- // the wizard buttons here.
- //
- // NOTE: If you do not wish this page to become active, return -1.
-
- /* setup static text with user and group strings */
- /* don't want to show this page if not installing into an existing MCC */
- if( 1 == mi.m_nExistingMCC)
- {
- /* dont display this page */
- SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
- return TRUE;
- }
- LoadString( mi.m_hModule, IDS_UG_DESC, szTemp, MAX_STR_SIZE);
-
- bResult = SetDlgItemText(hwndDlg,
- IDC_STATIC_DESC,
- szTemp);
- if(FALSE == bResult)
- {
- DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
- }
- LoadString( mi.m_hModule, IDS_UG_GB_DESC, szTemp, MAX_STR_SIZE);
-
- bResult = SetDlgItemText(hwndDlg,
- IDC_STATIC_SETTINGS,
- szTemp);
- if(FALSE == bResult)
- {
- DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
- }
-
- LoadString( mi.m_hModule, IDS_UG_RADIO_CREATE, szTemp, MAX_STR_SIZE);
-
- bResult = SetDlgItemText(hwndDlg,
- IDC_RADIO_USE_THIS_SERVER,
- szTemp);
- if(FALSE == bResult)
- {
- DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
- }
- LoadString( mi.m_hModule, IDS_UG_RADIO_EXIST, szTemp, MAX_STR_SIZE);
-
- bResult = SetDlgItemText(hwndDlg,
- IDC_RADIO_USE_EXISTING_SERVER,
- szTemp);
- if(FALSE == bResult)
- {
- DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
- }
- /* set defaults for text edit fields in this dialog */
- LoadDlgServerInfo(hwndDlg,
- mi.m_szUGHost,
- mi.m_nUGPort,
- mi.m_szUGSuffix,
- mi.m_szUserGroupAdmin,
- mi.m_szUserGroupAdminPW);
-
-
- CheckRadioButton(hwndDlg, IDC_RADIO_USE_THIS_SERVER,
- IDC_RADIO_USE_EXISTING_SERVER,
- ( (1 == mi.m_nExistingUG) ? IDC_RADIO_USE_EXISTING_SERVER :
- IDC_RADIO_USE_THIS_SERVER));
-
- if(1 == mi.m_nExistingUG)
- {
- EnableLDAPURLSettingsFields(hwndDlg, TRUE);
- }else{
- EnableLDAPURLSettingsFields(hwndDlg, FALSE);
- }
- CenterWindow(GetParent(hwndDlg));
- PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
- break;
- case PSN_KILLACTIVE:
- // This notification is sent upon deactivation of the property page.
- // Here you can do whatever might be necessary for this action, such
- // as saving the state of the controls. You should also reset the
- // the state of the wizard buttons here, as both the Back and Next
- // buttons should be active when you leave the AskOptions function.
- //
- // NOTE: If you do not want the page deactivated, return -1.
- PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
- break;
- case PSN_WIZBACK:
- // The user clicked the back button from the first property page.
- // Set the result code NS_WIZBACK to indicate this action and close
- // the property sheet using brute force. If this procedure is not
- // being used by the first property sheet, you should ignore this
- // notification and simply let windows go to the previous page.
- //
- // NOTE: To prevent the wizard from stepping back, return -1.
- SaveDialogInput_UG_Settings(hwndDlg);
- break;
- case PSN_WIZNEXT:
- // The user clicked the next button from the last property page.
- // Set the result code NS_WIZNEXT to indicate this action and close
- // the property sheet using brute force. If this procedure is not
- // being used by the last property sheet, you should ignore this
- // notification and simply let windows go to the next page.
- //
- // NOTE: To prevent the wizard from stepping ahead, return -1.
- SaveDialogInput_UG_Settings(hwndDlg);
- if(TRUE == (bValueReturned = Verify_UG_Settings() ) )
- {
- /* one of the settings was invalid */
- SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
- }
- break;
- case PSN_QUERYCANCEL:
- // This notification is sent when the user clicks the Cancel button.
- // It is also sent in response to the WM_CLOSE messages issued
- // by PSN_WIZBACK and PSN_WIZNEXT. Make sure that we only process
- // this message if the result is not back or next so that we don't
- // nuke the return value assigned by PSN_WIZBACK or PSN_WIZNEXT.
- //
- // NOTE: To prevent the cancel from occuring, return -1.
- if (mi.m_nResult != NS_WIZBACK && mi.m_nResult != NS_WIZNEXT)
- {
- if (QueryExit(hwndDlg))
- {
- mi.m_nResult = NS_WIZCANCEL;
- }
- else
- {
- SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
- bValueReturned = TRUE;
- }
- }
- break;
- }
- break;
- }
- return bValueReturned;
- }
- //////////////////////////////////////////////////////////////////////////////
- // SaveDialogInput_Server_Settings
- //
- // save settings entered in Server_Setting_DialogProc
- // called on back and next
- //
- //
- //
- void SaveDialogInput_Server_Settings(HWND hwndDlg)
- {
- BOOL bResult = FALSE;
- GetDlgItemText(hwndDlg,
- IDC_EDIT_SERVER_IDENTIFIER,
- mi.m_szServerIdentifier,
- MAX_STR_SIZE);
- /* get the suffix */
- GetDlgItemText(hwndDlg,
- IDC_EDIT_SUFFIX,
- mi.m_szInstanceSuffix,
- MAX_STR_SIZE);
- mi.m_nInstanceServerPort = (int ) GetDlgItemInt(hwndDlg,
- IDC_EDIT_SERVER_PORT,
- &bResult,
- TRUE);
- }
- //////////////////////////////////////////////////////////////////////////////
- // Verify_Server_Settings
- //
- // verify settings entered in Server_Setting_DialogProc
- //
- // Returns TRUE if there is an invalid setting
- // Returns FALSE if all settings are valid
- //
- // SideEffect: displays error (or writes to log in silent mode)
- BOOL Verify_Server_Settings()
- {
- BOOL bValueReturned = TRUE;
- if ( 0 == strlen(mi.m_szServerIdentifier) )
- {
- /* no value entered for server id */
- DSMessageBoxOK(ERR_NO_SERVER_ID_TITLE, ERR_NO_SERVER_ID, 0);
- } else if (FALSE == isValidServerID(mi.m_szServerIdentifier) )
- {
- /* server id is invalid */
- /* error reported by isValidServerID */
- } else if (0 == strlen(mi.m_szInstanceSuffix) && !mi.m_nExistingUG )
- {
- /* ok not to specify suffix when using existing UG hence above
- otherwise it must be specified */
- /* no value entered for suffix */
- DSMessageBoxOK(ERR_NO_SUFFIX_TITLE, ERR_NO_SUFFIX, 0);
- }else if (!mi.m_nExistingUG && !isValidDN(mi.m_szInstanceSuffix) )
- {
- /* don't check dn if ExistingUG since suffix is null */
- /* error message displayed by isValidDN */
- } else if ( !isValidPort(mi.m_nInstanceServerPort))
- {
- /* error displayed by isValidPort */
- }else{
- /* all items in this dialogue look good */
- bValueReturned = FALSE;
- }
- return bValueReturned;
- }
- //////////////////////////////////////////////////////////////////////////////
- // Server_Settings_DialogProc
- //
- // dialog proc to choose server settings
- //
- // used by typical mode
- //
- //
- static BOOL CALLBACK
- Server_Settings_DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
- {
- BOOL bValueReturned = FALSE;
- UINT uResult = 0;
- BOOL bResult = FALSE;
- HWND hCtrl;
- /* list of controls to be setup for 8bit input/display */
- INT h8bitControls[]={IDC_EDIT_SERVER_IDENTIFIER,
- IDC_EDIT_SUFFIX,
- -1};
- INT nCmdShow = SW_SHOW;
- static CHAR szSavedSuffix[MAX_STR_SIZE]="\0";
- switch (uMsg)
- {
- case WM_INITDIALOG:
- // This message is sent when the property page is first created. Here
- // you can perform any one time initialization that you require.
- Setup8bitInputDisplay(hwndDlg, h8bitControls);
- SendDlgItemMessage(hwndDlg, IDC_SPIN_SERVER_PORT, UDM_SETBUDDY, (WPARAM)GetDlgItem(hwndDlg, IDC_EDIT_SERVER_PORT), 0);
- SendDlgItemMessage(hwndDlg, IDC_SPIN_SERVER_PORT, UDM_SETRANGE, 0, MAKELONG((short)UD_MAXVAL, (short)1));
- my_strncpy(szSavedSuffix, mi.m_szInstanceSuffix, sizeof(szSavedSuffix));
- break;
- case WM_COMMAND:
- // Windows sends WM_COMMAND messages whenever the user clicks on
- // a control in your property page. If you need to perform some
- // special action, such as validating data or responding to a
- // button click, do it here.
-
- break;
- case WM_NOTIFY:
- // Windows sends WM_NOTIFY messages to your property page whenever
- // something interesting happens to the page. This could be page
- // activation/deactivation, a button click, etc. The wParam parameter
- // contains a pointer to the property page. The lParam parameter
- // contains a pointer to an NMHDR structure. The code field of this
- // structure contains the notification message code being sent. The
- // property sheet API allows you to alter the behavior of these
- // messages by returning a value for each message. To return a value,
- // use the SetWindowLong Windows SDK function.
- switch (((NMHDR*)lParam)->code)
- {
- case PSN_SETACTIVE:
- // This notification is sent upon activation of the property page.
- // The property sheet should be centered each time it is activated
- // in case the user has moved the stupid thing (this duplicates
- // InstallShield functionality). You should also set the state of
- // the wizard buttons here.
- //
- // NOTE: If you do not wish this page to become active, return -1.
- if(mi.m_nExistingUG)
- {
- /* hide suffix when creating config only directory */
- if( 0 != strlen(mi.m_szInstanceSuffix) )
- {
- my_strncpy(szSavedSuffix, mi.m_szInstanceSuffix, sizeof(szSavedSuffix));
- memset(mi.m_szInstanceSuffix, '\0', MAX_STR_SIZE);
- }
- nCmdShow = SW_HIDE;
- }else{
- my_strncpy(mi.m_szInstanceSuffix, szSavedSuffix, sizeof(mi.m_szInstanceSuffix));
- nCmdShow = SW_SHOW;
- }
- hCtrl = GetDlgItem(hwndDlg, IDC_EDIT_SUFFIX);
- ShowWindow(hCtrl,nCmdShow);
- hCtrl = GetDlgItem(hwndDlg, IDC_STATIC_SUFFIX);
- ShowWindow(hCtrl,nCmdShow);
- bResult = SetDlgItemText(hwndDlg,
- IDC_EDIT_SERVER_IDENTIFIER,
- mi.m_szServerIdentifier);
- if(FALSE == bResult)
- {
- DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
- }
- bResult = SetDlgItemText(hwndDlg,
- IDC_EDIT_SUFFIX,
- mi.m_szInstanceSuffix);
- if(FALSE == bResult)
- {
- DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
- }
- bResult = SetDlgItemInt(hwndDlg,
- IDC_EDIT_SERVER_PORT,
- mi.m_nInstanceServerPort,
- TRUE);
- if(FALSE == bResult)
- {
- DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
- }
-
- CenterWindow(GetParent(hwndDlg));
- PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
- break;
- case PSN_KILLACTIVE:
- // This notification is sent upon deactivation of the property page.
- // Here you can do whatever might be necessary for this action, such
- // as saving the state of the controls. You should also reset the
- // the state of the wizard buttons here, as both the Back and Next
- // buttons should be active when you leave the AskOptions function.
- //
- // NOTE: If you do not want the page deactivated, return -1.
- PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
- break;
- case PSN_WIZBACK:
- // The user clicked the back button from the first property page.
- // Set the result code NS_WIZBACK to indicate this action and close
- // the property sheet using brute force. If this procedure is not
- // being used by the first property sheet, you should ignore this
- // notification and simply let windows go to the previous page.
- //
- // NOTE: To prevent the wizard from stepping back, return -1.
- SaveDialogInput_Server_Settings(hwndDlg);
- // save the suffix typed in by the user
- my_strncpy(szSavedSuffix, mi.m_szInstanceSuffix, sizeof(szSavedSuffix));
- break;
- case PSN_WIZNEXT:
- // The user clicked the next button from the last property page.
- // Set the result code NS_WIZNEXT to indicate this action and close
- // the property sheet using brute force. If this procedure is not
- // being used by the last property sheet, you should ignore this
- // notification and simply let windows go to the next page.
- //
- // NOTE: To prevent the wizard from stepping ahead, return -1.
- SaveDialogInput_Server_Settings(hwndDlg);
- // save the suffix typed in by the user
- my_strncpy(szSavedSuffix, mi.m_szInstanceSuffix, sizeof(szSavedSuffix));
- if( TRUE == (bValueReturned = Verify_Server_Settings()) )
- {
- /* one of the settings was invalid stay on this page */
- SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
- }
- break;
- case PSN_QUERYCANCEL:
- // This notification is sent when the user clicks the Cancel button.
- // It is also sent in response to the WM_CLOSE messages issued
- // by PSN_WIZBACK and PSN_WIZNEXT. Make sure that we only process
- // this message if the result is not back or next so that we don't
- // nuke the return value assigned by PSN_WIZBACK or PSN_WIZNEXT.
- //
- // NOTE: To prevent the cancel from occuring, return -1.
- if (mi.m_nResult != NS_WIZBACK && mi.m_nResult != NS_WIZNEXT)
- {
- if (QueryExit(hwndDlg))
- {
- mi.m_nResult = NS_WIZCANCEL;
- }
- else
- {
- SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
- bValueReturned = TRUE;
- }
- }
- break;
- }
- break;
- }
- return bValueReturned;
- }
- //////////////////////////////////////////////////////////////////////////////
- // BOOL SaveDialogPasswords
- //
- // helper for ROOTDN and SUITESPOTDN Dialogs
- //
- //
- // saves passwords entered into dialog
- //
- //
- void SaveDialogPasswords(HWND hwndDlg, PSZ pszPassword, PSZ pszPasswordAgain)
- {
- GetDlgItemText(hwndDlg,
- IDC_EDIT_PASSWORD,
- pszPassword,
- MAX_STR_SIZE);
- GetDlgItemText(hwndDlg,
- IDC_EDIT_PASSWORD_AGAIN,
- pszPasswordAgain,
- MAX_STR_SIZE);
- }
- //////////////////////////////////////////////////////////////////////////////
- // BOOL LoadDialogPasswords
- //
- // helper for ROOTDN and SUITESPOTDN Dialogs
- //
- //
- // loads passwords entered into dialog
- //
- //
- void LoadDialogPasswords(HWND hwndDlg, PSZ pszPassword, PSZ pszPasswordAgain)
- {
- BOOL bResult;
- bResult = SetDlgItemText(hwndDlg,
- IDC_EDIT_PASSWORD,
- pszPassword);
- if(FALSE == bResult)
- {
- DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
- }
- if (pszPasswordAgain)
- {
- bResult = SetDlgItemText(hwndDlg,
- IDC_EDIT_PASSWORD_AGAIN,
- pszPasswordAgain);
- if(FALSE == bResult)
- {
- DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
- }
- }
- }
- //////////////////////////////////////////////////////////////////////////////
- // BOOL VerifyPasswords
- //
- // helper for ROOTDN and SUITESPOTDN Dialogs
- //
- //
- // check that passwords are valid
- //
- // Returns TRUE if there is an invalid setting
- // Returns False if all settings are valid
- //
- // SideEffect: displays error (or writes to log in silent mode)
-
- BOOL VerifyPasswords(PSZ pszPassword, PSZ pszPasswordAgain, UINT min_pw_len)
- {
- BOOL bValueReturned = TRUE;
- if (min_pw_len > strlen(pszPassword))
- {
- /* password failed minimum length check */
- DSMessageBoxOK(ERR_PW_TOO_SHORT_TITLE, ERR_PW_TOO_SHORT, 0,
- min_pw_len);
-
- } else if ( contains8BitChars(pszPassword) )
- {
- /* check to make sure pw doesn't contain any 8bit chars */
- DSMessageBoxOK(ERR_8BIT_PW_TITLE, ERR_8BIT_PW, 0);
- } else if ( 0 == strlen(pszPasswordAgain) )
- {
- /* second password to verify missing */
- DSMessageBoxOK(ERR_NO_PW_AGAIN_TITLE, ERR_NO_PW_AGAIN, 0);
- } else if ( 0 != lstrcmp(pszPassword, pszPasswordAgain) )
- {
- /* passwords don't match */
- DSMessageBoxOK(ERR_PW_DIFFER_TITLE, ERR_PW_DIFFER, 0);
- }else{
- /* passwords satisfied all checks so return false */
- bValueReturned = FALSE;
- }
- return bValueReturned;
- }
- //////////////////////////////////////////////////////////////////////////////
- // SaveDialogInput_RootDN
- //
- // saves input in root dn DialogProc
- //
- //
- //
- //
- void SaveDialogInput_ROOTDN(HWND hwndDlg)
- {
- BOOL bValueReturned = FALSE;
- UINT uResult = 0;
- BOOL bResult = FALSE;
- GetDlgItemText(hwndDlg,
- IDC_EDIT_UNRESTRICTED_USER,
- mi.m_szInstanceUnrestrictedUser,
- MAX_STR_SIZE);
- SaveDialogPasswords(hwndDlg,
- mi.m_szInstancePassword,
- mi.m_szInstancePasswordAgain);
-
- }
- //////////////////////////////////////////////////////////////////////////////
- // Verify_RootDN
- //
- // verifies input in root dn DialogProc
- //
- //
- // Returns TRUE if there is an invalid setting
- // Returns FALSE if all settings are valid
- //
- // SideEffect: displays error (or writes to log in silent mode)
- BOOL Verify_ROOTDN()
- {
- BOOL bValueReturned = FALSE;
- if ( 0 == strlen(mi.m_szInstanceUnrestrictedUser) )
- {
- /* no value entered */
- DSMessageBoxOK(ERR_NO_ROOT_DN_TITLE, ERR_NO_ROOT_DN, 0);
- bValueReturned = TRUE;
- }else if ( !isValidDN(mi.m_szInstanceUnrestrictedUser) )
- {
- /* error message displayed by isvalidDN */
- bValueReturned = TRUE;
- } else
- {
- /* only bother to check passwords if username is valid */
- bValueReturned = VerifyPasswords(mi.m_szInstancePassword,
- mi.m_szInstancePasswordAgain,
- SLAPD_MIN_PW_LEN);
- }
- return bValueReturned;
- }
- //////////////////////////////////////////////////////////////////////////////
- // RootDN_DialogProc
- //
- // dialog proc for the RootDN install page
- //
- //
- //
- //
- static BOOL CALLBACK
- RootDN_DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
- {
- BOOL bValueReturned = FALSE;
- UINT uResult = 0;
- BOOL bResult = FALSE;
-
- /* list of controls to be setup for 8bit input/display */
- INT h8bitControls[]={IDC_EDIT_UNRESTRICTED_USER,
- IDC_EDIT_PASSWORD,
- IDC_EDIT_PASSWORD_AGAIN,
- -1};
- switch (uMsg)
- {
- case WM_INITDIALOG:
- // This message is sent when the property page is first created. Here
- // you can perform any one time initialization that you require.
- Setup8bitInputDisplay(hwndDlg, h8bitControls);
- break;
- case WM_COMMAND:
- // Windows sends WM_COMMAND messages whenever the user clicks on
- // a control in your property page. If you need to perform some
- // special action, such as validating data or responding to a
- // button click, do it here.
-
- break;
- case WM_NOTIFY:
- // Windows sends WM_NOTIFY messages to your property page whenever
- // something interesting happens to the page. This could be page
- // activation/deactivation, a button click, etc. The wParam parameter
- // contains a pointer to the property page. The lParam parameter
- // contains a pointer to an NMHDR structure. The code field of this
- // structure contains the notification message code being sent. The
- // property sheet API allows you to alter the behavior of these
- // messages by returning a value for each message. To return a value,
- // use the SetWindowLong Windows SDK function.
- switch (((NMHDR*)lParam)->code)
- {
- case PSN_SETACTIVE:
- // This notification is sent upon activation of the property page.
- // The property sheet should be centered each time it is activated
- // in case the user has moved the stupid thing (this duplicates
- // InstallShield functionality). You should also set the state of
- // the wizard buttons here.
- //
- // NOTE: If you do not wish this page to become active, return -1.
- bResult = SetDlgItemText(hwndDlg,
- IDC_EDIT_UNRESTRICTED_USER,
- mi.m_szInstanceUnrestrictedUser);
- if(FALSE == bResult)
- {
- DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
- }
- LoadDialogPasswords(hwndDlg,
- mi.m_szInstancePassword,
- mi.m_szInstancePasswordAgain);
- CenterWindow(GetParent(hwndDlg));
- PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
- break;
- case PSN_KILLACTIVE:
- // This notification is sent upon deactivation of the property page.
- // Here you can do whatever might be necessary for this action, such
- // as saving the state of the controls. You should also reset the
- // the state of the wizard buttons here, as both the Back and Next
- // buttons should be active when you leave the AskOptions function.
- //
- // NOTE: If you do not want the page deactivated, return -1.
- PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
- break;
- case PSN_WIZBACK:
- // The user clicked the back button from the first property page.
- // Set the result code NS_WIZBACK to indicate this action and close
- // the property sheet using brute force. If this procedure is not
- // being used by the first property sheet, you should ignore this
- // notification and simply let windows go to the previous page.
- //
- // NOTE: To prevent the wizard from stepping back, return -1.
- SaveDialogInput_ROOTDN(hwndDlg);
- break;
- case PSN_WIZNEXT:
- // The user clicked the next button from the last property page.
- // Set the result code NS_WIZNEXT to indicate this action and close
- // the property sheet using brute force. If this procedure is not
- // being used by the last property sheet, you should ignore this
- // notification and simply let windows go to the next page.
- //
- // NOTE: To prevent the wizard from stepping ahead, return -1.
- SaveDialogInput_ROOTDN(hwndDlg);
- if ( FALSE == (bValueReturned = Verify_ROOTDN() ) )
- {
- /* all settings on this dialogue look good */
- /* verify ldap settings */
- if (0 != verify_ldap_settings() )
- {
- /* dont allow next until settings corrected */
- SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
- bValueReturned = TRUE;
- } else
- {
- /* set ldap settings for other installs */
- set_ldap_settings();
- }
-
- /* if not advanced mode move on to other installs */
- if (CUSTOMMODE != MODE)
- {
- mi.m_nResult = NS_WIZNEXT;
- SendMessage(GetParent(hwndDlg), WM_CLOSE, 0, 0);
- }
- } else
- {
- /* one of the settings was invalid, stay on this page */
- SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
- }
- break;
- case PSN_QUERYCANCEL:
- // This notification is sent when the user clicks the Cancel button.
- // It is also sent in response to the WM_CLOSE messages issued
- // by PSN_WIZBACK and PSN_WIZNEXT. Make sure that we only process
- // this message if the result is not back or next so that we don't
- // nuke the return value assigned by PSN_WIZBACK or PSN_WIZNEXT.
- //
- // NOTE: To prevent the cancel from occuring, return -1.
- if (mi.m_nResult != NS_WIZBACK && mi.m_nResult != NS_WIZNEXT)
- {
- if (QueryExit(hwndDlg))
- {
- mi.m_nResult = NS_WIZCANCEL;
- }
- else
- {
- SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
- bValueReturned = TRUE;
- }
- }
- break;
- }
- break;
- }
- return bValueReturned;
- }
- //////////////////////////////////////////////////////////////////////////////
- //
- // SaveDialogInput_SuitespotId
- //
- //
- //
- void SaveDialogInput_SuitespotId(HWND hwndDlg)
- {
- GetDlgItemText(hwndDlg,
- IDC_EDIT_SUITESPOT_USER,
- mi.m_szSsptUid,
- MAX_STR_SIZE);
- SaveDialogPasswords(hwndDlg,
- mi.m_szSsptUidPw,
- mi.m_szSsptUidPwAgain);
- }
- //////////////////////////////////////////////////////////////////////////////
- //
- // Verify_SuitespotId
- //
- // Returns TRUE if there is an invalid setting
- // Returns FALSE if all settings are valid
- //
- // SideEffect: displays error (or writes to log in silent mode)
- BOOL Verify_SuitespotId()
- {
- BOOL bValueReturned = FALSE;
- if ( 0 == strlen(mi.m_szSsptUid) )
- {
- /* no value entered for sspt user */
- DSMessageBoxOK(ERR_NO_SS_ADMIN_TITLE, ERR_NO_SS_ADMIN, 0);
- bValueReturned = TRUE;
- } else if (!isAValidDN(mi.m_szSsptUid) &&
- contains8BitChars(mi.m_szSsptUid))
- {
- /* admin uid value not 7 bit */
- DSMessageBoxOK(ERR_8BIT_UID_TITLE, ERR_8BIT_UID, 0);
- bValueReturned = TRUE;
- } else
- {
- /* only bother to check passwords if username is valid */
- bValueReturned = VerifyPasswords(mi.m_szSsptUidPw,
- mi.m_szSsptUidPwAgain,
- SSPT_MIN_PW_LEN);
- }
- return bValueReturned;
- }
- //////////////////////////////////////////////////////////////////////////////
- // SuitespotID_DialogProc
- //
- // dialog proc for the SUITESPOTID install page
- //
- //
- //
- //
- static BOOL CALLBACK
- SuitespotID_DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
- {
- BOOL bValueReturned = FALSE;
- UINT uResult = 0;
- BOOL bResult = FALSE;
-
- /* list of controls to be setup for 8bit input/display */
- INT h8bitControls[]={IDC_EDIT_SUITESPOT_USER,
- IDC_EDIT_PASSWORD,
- IDC_EDIT_PASSWORD_AGAIN,
- -1};
- switch (uMsg)
- {
- case WM_INITDIALOG:
- // This message is sent when the property page is first created. Here
- // you can perform any one time initialization that you require.
- Setup8bitInputDisplay(hwndDlg, h8bitControls);
- break;
- case WM_COMMAND:
- // Windows sends WM_COMMAND messages whenever the user clicks on
- // a control in your property page. If you need to perform some
- // special action, such as validating data or responding to a
- // button click, do it here.
-
- break;
- case WM_NOTIFY:
- // Windows sends WM_NOTIFY messages to your property page whenever
- // something interesting happens to the page. This could be page
- // activation/deactivation, a button click, etc. The wParam parameter
- // contains a pointer to the property page. The lParam parameter
- // contains a pointer to an NMHDR structure. The code field of this
- // structure contains the notification message code being sent. The
- // property sheet API allows you to alter the behavior of these
- // messages by returning a value for each message. To return a value,
- // use the SetWindowLong Windows SDK function.
- switch (((NMHDR*)lParam)->code)
- {
- case PSN_SETACTIVE:
- // This notification is sent upon activation of the property page.
- // The property sheet should be centered each time it is activated
- // in case the user has moved the stupid thing (this duplicates
- // InstallShield functionality). You should also set the state of
- // the wizard buttons here.
- //
- // NOTE: If you do not wish this page to become active, return -1.
- if(1 == mi.m_nExistingMCC)
- {
- /* don't display this dialog if using existing MCC since asked for it
- there */
- SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
- return TRUE;
- }
- bResult = SetDlgItemText(hwndDlg,
- IDC_EDIT_SUITESPOT_USER,
- mi.m_szSsptUid);
- if(FALSE == bResult)
- {
- DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
- }
- LoadDialogPasswords(hwndDlg,
- mi.m_szSsptUidPw,
- mi.m_szSsptUidPwAgain);
- CenterWindow(GetParent(hwndDlg));
- PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
- break;
- case PSN_KILLACTIVE:
- // This notification is sent upon deactivation of the property page.
- // Here you can do whatever might be necessary for this action, such
- // as saving the state of the controls. You should also reset the
- // the state of the wizard buttons here, as both the Back and Next
- // buttons should be active when you leave the AskOptions function.
- //
- // NOTE: If you do not want the page deactivated, return -1.
- PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
- break;
- case PSN_WIZBACK:
- // The user clicked the back button from the first property page.
- // Set the result code NS_WIZBACK to indicate this action and close
- // the property sheet using brute force. If this procedure is not
- // being used by the first property sheet, you should ignore this
- // notification and simply let windows go to the previous page.
- //
- // NOTE: To prevent the wizard from stepping back, return -1.
- SaveDialogInput_SuitespotId(hwndDlg);
- // in express mode this is the first dialog, so set back to go to other module */
- if (EXPRESSMODE == MODE)
- {
- mi.m_nResult = NS_WIZBACK;
- SendMessage(GetParent(hwndDlg), WM_CLOSE, 0, 0);
- }
-
- break;
- case PSN_WIZNEXT:
- // The user clicked the next button from the last property page.
- // Set the result code NS_WIZNEXT to indicate this action and close
- // the property sheet using brute force. If this procedure is not
- // being used by the last property sheet, you should ignore this
- // notification and simply let windows go to the next page.
- //
- // NOTE: To prevent the wizard from stepping ahead, return -1.
- SaveDialogInput_SuitespotId(hwndDlg);
- if(TRUE == (bValueReturned = Verify_SuitespotId() ) )
- {
- /* one of the settings was invalid stay on this page */
- SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
- }
-
- break;
- case PSN_QUERYCANCEL:
- // This notification is sent when the user clicks the Cancel button.
- // It is also sent in response to the WM_CLOSE messages issued
- // by PSN_WIZBACK and PSN_WIZNEXT. Make sure that we only process
- // this message if the result is not back or next so that we don't
- // nuke the return value assigned by PSN_WIZBACK or PSN_WIZNEXT.
- //
- // NOTE: To prevent the cancel from occuring, return -1.
- if (mi.m_nResult != NS_WIZBACK && mi.m_nResult != NS_WIZNEXT)
- {
- if (QueryExit(hwndDlg))
- {
- mi.m_nResult = NS_WIZCANCEL;
- }
- else
- {
- SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
- bValueReturned = TRUE;
- }
- }
- break;
- }
- break;
- }
- return bValueReturned;
- }
- //////////////////////////////////////////////////////////////////////////////
- // Admin_ID_Only_DialogProc
- //
- // dialog proc for the ADMIN_ID_ONLY install page
- //
- //
- //
- //
- static BOOL CALLBACK
- Admin_ID_Only_DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
- {
- BOOL bValueReturned = FALSE;
- UINT uResult = 0;
- BOOL bResult = FALSE;
-
- /* list of controls to be setup for 8bit input/display */
- INT h8bitControls[]={IDC_EDIT_SUITESPOT_USER,
- IDC_EDIT_PASSWORD,
- -1};
- switch (uMsg)
- {
- case WM_INITDIALOG:
- // This message is sent when the property page is first created. Here
- // you can perform any one time initialization that you require.
- Setup8bitInputDisplay(hwndDlg, h8bitControls);
- break;
- case WM_COMMAND:
- // Windows sends WM_COMMAND messages whenever the user clicks on
- // a control in your property page. If you need to perform some
- // special action, such as validating data or responding to a
- // button click, do it here.
-
- break;
- case WM_NOTIFY:
- // Windows sends WM_NOTIFY messages to your property page whenever
- // something interesting happens to the page. This could be page
- // activation/deactivation, a button click, etc. The wParam parameter
- // contains a pointer to the property page. The lParam parameter
- // contains a pointer to an NMHDR structure. The code field of this
- // structure contains the notification message code being sent. The
- // property sheet API allows you to alter the behavior of these
- // messages by returning a value for each message. To return a value,
- // use the SetWindowLong Windows SDK function.
- switch (((NMHDR*)lParam)->code)
- {
- case PSN_SETACTIVE:
- // This notification is sent upon activation of the property page.
- // The property sheet should be centered each time it is activated
- // in case the user has moved the stupid thing (this duplicates
- // InstallShield functionality). You should also set the state of
- // the wizard buttons here.
- //
- // NOTE: If you do not wish this page to become active, return -1.
- bResult = SetDlgItemText(hwndDlg,
- IDC_EDIT_SUITESPOT_USER,
- mi.m_szMCCBindAs);
- if(FALSE == bResult)
- {
- DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
- }
- LoadDialogPasswords(hwndDlg,
- mi.m_szMCCPw,
- 0);
- CenterWindow(GetParent(hwndDlg));
- PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
- break;
- case PSN_KILLACTIVE:
- // This notification is sent upon deactivation of the property page.
- // Here you can do whatever might be necessary for this action, such
- // as saving the state of the controls. You should also reset the
- // the state of the wizard buttons here, as both the Back and Next
- // buttons should be active when you leave the AskOptions function.
- //
- // NOTE: If you do not want the page deactivated, return -1.
- PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
- break;
- case PSN_WIZBACK:
- // The user clicked the back button from the first property page.
- // Set the result code NS_WIZBACK to indicate this action and close
- // the property sheet using brute force. If this procedure is not
- // being used by the first property sheet, you should ignore this
- // notification and simply let windows go to the previous page.
- //
- // NOTE: To prevent the wizard from stepping back, return -1.
- GetDlgItemText(hwndDlg,
- IDC_EDIT_SUITESPOT_USER,
- mi.m_szMCCBindAs,
- MAX_STR_SIZE);
- GetDlgItemText(hwndDlg,
- IDC_EDIT_PASSWORD,
- mi.m_szMCCPw,
- MAX_STR_SIZE);
- // in express mode this is the first dialog, so set back to go to other module */
- if (EXPRESSMODE == MODE)
- {
- mi.m_nResult = NS_WIZBACK;
- SendMessage(GetParent(hwndDlg), WM_CLOSE, 0, 0);
- }
-
- break;
- case PSN_WIZNEXT:
- // The user clicked the next button from the last property page.
- // Set the result code NS_WIZNEXT to indicate this action and close
- // the property sheet using brute force. If this procedure is not
- // being used by the last property sheet, you should ignore this
- // notification and simply let windows go to the next page.
- //
- // NOTE: To prevent the wizard from stepping ahead, return -1.
- GetDlgItemText(hwndDlg,
- IDC_EDIT_SUITESPOT_USER,
- mi.m_szMCCBindAs,
- MAX_STR_SIZE);
- GetDlgItemText(hwndDlg,
- IDC_EDIT_PASSWORD,
- mi.m_szMCCPw,
- MAX_STR_SIZE);
- if(TRUE == (bValueReturned = Verify_MCC_Settings() ) )
- {
- /* one of the settings was invalid stay on this page */
- SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
- }
-
- break;
- case PSN_QUERYCANCEL:
- // This notification is sent when the user clicks the Cancel button.
- // It is also sent in response to the WM_CLOSE messages issued
- // by PSN_WIZBACK and PSN_WIZNEXT. Make sure that we only process
- // this message if the result is not back or next so that we don't
- // nuke the return value assigned by PSN_WIZBACK or PSN_WIZNEXT.
- //
- // NOTE: To prevent the cancel from occuring, return -1.
- if (mi.m_nResult != NS_WIZBACK && mi.m_nResult != NS_WIZNEXT)
- {
- if (QueryExit(hwndDlg))
- {
- mi.m_nResult = NS_WIZCANCEL;
- }
- else
- {
- SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
- bValueReturned = TRUE;
- }
- }
- break;
- }
- break;
- }
- return bValueReturned;
- }
- //////////////////////////////////////////////////////////////////////////////
- // Choose_Replication_DialogProc
- //
- // choose the type of replicatin to do, determine which pages to ask next
- //
- //
- //
- //
- static BOOL CALLBACK
- Choose_Replication_DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
- {
- BOOL bValueReturned = FALSE;
- UINT uResult = 0;
- BOOL bResult = FALSE;
-
- switch (uMsg)
- {
- case WM_INITDIALOG:
- // This message is sent when the property page is first created. Here
- // you can perform any one time initialization that you require.
-
- break;
- case WM_COMMAND:
- // Windows sends WM_COMMAND messages whenever the user clicks on
- // a control in your property page. If you need to perform some
- // special action, such as validating data or responding to a
- // button click, do it here.
- /* consumer replication */
- if(BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_RADIO_NO_CONSUMER_REPLICATION ) )
- {
- mi.m_nSetupConsumerReplication = NO_REPLICATION;
- }else if(BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_RADIO_CONSUMER_CIR ) ){
- mi.m_nSetupConsumerReplication = CONSUMER_CIR_REPLICATION;
- }else if(BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_RADIO_CONSUMER_SIR ) ){
- mi.m_nSetupConsumerReplication = CONSUMER_SIR_REPLICATION;
- }
- /* supplier replication */
- if( BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_RADIO_NO_SUPPLIER_REPLICATION ) )
- {
- mi.m_nSetupSupplierReplication = NO_REPLICATION;
- }else if(BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_RADIO_SUPPLIER_CIR ) ){
- mi.m_nSetupSupplierReplication = SUPPLIER_CIR_REPLICATION;
- }else if(BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_RADIO_SUPPLIER_SIR ) ){
- mi.m_nSetupSupplierReplication = SUPPLIER_SIR_REPLICATION;
- }
-
- break;
- case WM_NOTIFY:
- // Windows sends WM_NOTIFY messages to your property page whenever
- // something interesting happens to the page. This could be page
- // activation/deactivation, a button click, etc. The wParam parameter
- // contains a pointer to the property page. The lParam parameter
- // contains a pointer to an NMHDR structure. The code field of this
- // structure contains the notification message code being sent. The
- // property sheet API allows you to alter the behavior of these
- // messages by returning a value for each message. To return a value,
- // use the SetWindowLong Windows SDK function.
- switch (((NMHDR*)lParam)->code)
- {
- case PSN_SETACTIVE:
- // This notification is sent upon activation of the property page.
- // The property sheet should be centered each time it is activated
- // in case the user has moved the stupid thing (this duplicates
- // InstallShield functionality). You should also set the state of
- // the wizard buttons here.
- //
- // NOTE: If you do not wish this page to become active, return -1.
- /* set buttons for appropriate replication type */
- if(CONSUMER_CIR_REPLICATION == mi.m_nSetupConsumerReplication)
- {
- CheckDlgButton(hwndDlg, IDC_RADIO_CONSUMER_CIR, BST_CHECKED);
- }else if(CONSUMER_SIR_REPLICATION == mi.m_nSetupConsumerReplication){
- CheckDlgButton(hwndDlg, IDC_RADIO_CONSUMER_SIR, BST_CHECKED);
- }else{
- CheckDlgButton(hwndDlg, IDC_RADIO_NO_CONSUMER_REPLICATION, BST_CHECKED);
- }
- if(SUPPLIER_CIR_REPLICATION == mi.m_nSetupSupplierReplication)
- {
- CheckDlgButton(hwndDlg, IDC_RADIO_SUPPLIER_CIR, BST_CHECKED);
- }else if(SUPPLIER_SIR_REPLICATION == mi.m_nSetupSupplierReplication){
- CheckDlgButton(hwndDlg, IDC_RADIO_SUPPLIER_SIR, BST_CHECKED);
- }else{
- CheckDlgButton(hwndDlg, IDC_RADIO_NO_SUPPLIER_REPLICATION, BST_CHECKED);
- }
- CenterWindow(GetParent(hwndDlg));
- PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
- break;
- case PSN_KILLACTIVE:
- // This notification is sent upon deactivation of the property page.
- // Here you can do whatever might be necessary for this action, such
- // as saving the state of the controls. You should also reset the
- // the state of the wizard buttons here, as both the Back and Next
- // buttons should be active when you leave the AskOptions function.
- //
- // NOTE: If you do not want the page deactivated, return -1.
- PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
- break;
- case PSN_WIZBACK:
- // The user clicked the back button from the first property page.
- // Set the result code NS_WIZBACK to indicate this action and close
- // the property sheet using brute force. If this procedure is not
- // being used by the first property sheet, you should ignore this
- // notification and simply let windows go to the previous page.
- //
- // NOTE: To prevent the wizard from stepping back, return -1.
-
- // simple dialog, all button state gets saved in WM_COMMAND proccessing
- break;
- case PSN_WIZNEXT:
- // The user clicked the next button from the last property page.
- // Set the result code NS_WIZNEXT to indicate this action and close
- // the property sheet using brute force. If this procedure is not
- // being used by the last property sheet, you should ignore this
- // notification and simply let windows go to the next page.
- //
- // NOTE: To prevent the wizard from stepping ahead, return -1.
-
- // simple dialog, all button state gets saved in WM_COMMAND proccessing
- break;
- case PSN_QUERYCANCEL:
- // This notification is sent when the user clicks the Cancel button.
- // It is also sent in response to the WM_CLOSE messages issued
- // by PSN_WIZBACK and PSN_WIZNEXT. Make sure that we only process
- // this message if the result is not back or next so that we don't
- // nuke the return value assigned by PSN_WIZBACK or PSN_WIZNEXT.
- //
- // NOTE: To prevent the cancel from occuring, return -1.
- if (mi.m_nResult != NS_WIZBACK && mi.m_nResult != NS_WIZNEXT)
- {
- if (QueryExit(hwndDlg))
- {
- mi.m_nResult = NS_WIZCANCEL;
- }
- else
- {
- SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
- bValueReturned = TRUE;
- }
- }
- break;
- }
- break;
- }
- return bValueReturned;
- }
- //////////////////////////////////////////////////////////////////////////////
- // SaveDialogInput_Consumer_Replication
- //
- // save settings from ConsumerReplication Dialog
- //
- //
- //
- //
- void SaveDialogInput_Consumer_Replication(HWND hwndDlg)
- {
- if ( CONSUMER_SIR_REPLICATION == mi.m_nSetupConsumerReplication )
- {
- GetDlgItemText(hwndDlg,
- IDC_EDIT_SUPPLIER_DN,
- mi.m_szSupplierDN,
- MAX_STR_SIZE);
- SaveDialogPasswords(hwndDlg,
- mi.m_szSupplierPW,
- mi.m_szSupplierPWAgain);
- }
- }
- //////////////////////////////////////////////////////////////////////////////
- // Verify_Consumer_Replication
- //
- // save settings from ConsumerReplication Dialog
- //
- //
- // Returns TRUE if there is an invalid setting
- // Returns FALSE if all settings are valid
- //
- // SideEffect: displays error (or writes to log in silent mode)
- BOOL Verify_Consumer_Replication()
- {
- BOOL bValueReturned = FALSE;
- /* only check if configuring consumer replication */
- if ( CONSUMER_SIR_REPLICATION == mi.m_nSetupConsumerReplication )
- {
- if ( 0 == strlen(mi.m_szSupplierDN) )
- {
- /* no value entered for Supplier DN */
- DSMessageBoxOK(ERR_NO_SUPPLIER_DN_TITLE,
- ERR_NO_SUPPLIER_DN, 0);
- bValueReturned = TRUE;
- }else if ( !isValidDN(mi.m_szSupplierDN) )
- {
- /* error message displayed by isvalidDN */
- bValueReturned = TRUE;
- } else
- {
- bValueReturned = VerifyPasswords(mi.m_szSupplierPW,
- mi.m_szSupplierPWAgain,
- SLAPD_MIN_PW_LEN);
- }
- }
- return bValueReturned;
- }
- //////////////////////////////////////////////////////////////////////////////
- // Consumer_Replication_DialogProc
- //
- // ask common settings needed for this server to be a consumer
- //
- //
- //
- //
- static BOOL CALLBACK
- Consumer_Replication_DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
- {
- BOOL bValueReturned = FALSE;
- UINT uResult = 0;
- BOOL bResult = FALSE;
-
- /* list of controls to be setup for 8bit input/display */
- INT h8bitControls[]={IDC_EDIT_SUPPLIER_DN,
- IDC_EDIT_PASSWORD,
- IDC_EDIT_PASSWORD_AGAIN,
- -1};
-
- switch (uMsg)
- {
- case WM_INITDIALOG:
- // This message is sent when the property page is first created. Here
- // you can perform any one time initialization that you require.
- Setup8bitInputDisplay(hwndDlg, h8bitControls);
-
- break;
- case WM_COMMAND:
- // Windows sends WM_COMMAND messages whenever the user clicks on
- // a control in your property page. If you need to perform some
- // special action, such as validating data or responding to a
- // button click, do it here.
-
- break;
- case WM_NOTIFY:
- // Windows sends WM_NOTIFY messages to your property page whenever
- // something interesting happens to the page. This could be page
- // activation/deactivation, a button click, etc. The wParam parameter
- // contains a pointer to the property page. The lParam parameter
- // contains a pointer to an NMHDR structure. The code field of this
- // structure contains the notification message code being sent. The
- // property sheet API allows you to alter the behavior of these
- // messages by returning a value for each message. To return a value,
- // use the SetWindowLong Windows SDK function.
- switch (((NMHDR*)lParam)->code)
- {
- case PSN_SETACTIVE:
- // This notification is sent upon activation of the property page.
- // The property sheet should be centered each time it is activated
- // in case the user has moved the stupid thing (this duplicates
- // InstallShield functionality). You should also set the state of
- // the wizard buttons here.
- //
- // NOTE: If you do not wish this page to become active, return -1.
- if( CONSUMER_SIR_REPLICATION != mi.m_nSetupConsumerReplication )
- {
- /* we only want this dialog for Consumer SIR replication */
- SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
- return TRUE;
- }
- bResult = SetDlgItemText(hwndDlg,
- IDC_EDIT_SUPPLIER_DN,
- mi.m_szSupplierDN);
- if(FALSE == bResult)
- {
- DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
- }
-
- LoadDialogPasswords(hwndDlg,
- mi.m_szSupplierPW,
- mi.m_szSupplierPWAgain);
- CenterWindow(GetParent(hwndDlg));
- PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
- break;
- case PSN_KILLACTIVE:
- // This notification is sent upon deactivation of the property page.
- // Here you can do whatever might be necessary for this action, such
- // as saving the state of the controls. You should also reset the
- // the state of the wizard buttons here, as both the Back and Next
- // buttons should be active when you leave the AskOptions function.
- //
- // NOTE: If you do not want the page deactivated, return -1.
- PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
- break;
- case PSN_WIZBACK:
- // The user clicked the back button from the first property page.
- // Set the result code NS_WIZBACK to indicate this action and close
- // the property sheet using brute force. If this procedure is not
- // being used by the first property sheet, you should ignore this
- // notification and simply let windows go to the previous page.
- //
- // NOTE: To prevent the wizard from stepping back, return -1.
- SaveDialogInput_Consumer_Replication(hwndDlg);
- break;
- case PSN_WIZNEXT:
- // The user clicked the next button from the last property page.
- // Set the result code NS_WIZNEXT to indicate this action and close
- // the property sheet using brute force. If this procedure is not
- // being used by the last property sheet, you should ignore this
- // notification and simply let windows go to the next page.
- //
- // NOTE: To prevent the wizard from stepping ahead, return -1.
- SaveDialogInput_Consumer_Replication(hwndDlg);
- if( TRUE == (bValueReturned = Verify_Consumer_Replication() ) )
- {
- /* a setting was invalid stay on this page*/
- SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
- }else{
- /* all settings on this dialogue look good */
-
- /* these settings were specified, ok to use them */
- mi.m_nUseSupplierSettings = 1;
- }
- break;
- case PSN_QUERYCANCEL:
- // This notification is sent when the user clicks the Cancel button.
- // It is also sent in response to the WM_CLOSE messages issued
- // by PSN_WIZBACK and PSN_WIZNEXT. Make sure that we only process
- // this message if the result is not back or next so that we don't
- // nuke the return value assigned by PSN_WIZBACK or PSN_WIZNEXT.
- //
- // NOTE: To prevent the cancel from occuring, return -1.
- if (mi.m_nResult != NS_WIZBACK && mi.m_nResult != NS_WIZNEXT)
- {
- if (QueryExit(hwndDlg))
- {
- mi.m_nResult = NS_WIZCANCEL;
- }
- else
- {
- SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
- bValueReturned = TRUE;
- }
- }
- break;
- }
- break;
- }
- return bValueReturned;
- }
- //////////////////////////////////////////////////////////////////////////////
- // SaveDialogInput_Supplier_Replication
- //
- // save supplier settings
- //
- //
- //
- //
- void SaveDialogInput_Supplier_Replication(HWND hwndDlg)
- {
- GetDlgItemText(hwndDlg,
- IDC_EDIT_CHANGELOG_DB_DIR,
- mi.m_szChangeLogDbDir,
- MAX_STR_SIZE);
- GetDlgItemText(hwndDlg,
- IDC_EDIT_CHANGELOG_DB_SUFFIX,
- mi.m_szChangeLogSuffix,
- MAX_STR_SIZE);
- }
- //////////////////////////////////////////////////////////////////////////////
- // Verify_Supplier_Replication
- //
- // save supplier settings
- //
- //
- // Returns TRUE if there is an invalid setting
- // Returns FALSE if all settings are valid
- //
- // SideEffect: displays error (or writes to log in silent mode)
- BOOL Verify_Supplier_Replication()
- {
- BOOL bValueReturned = TRUE;
- if ( 0 == strlen(mi.m_szChangeLogDbDir) )
- {
- DSMessageBoxOK(ERR_NO_CHANGELOG_DB_TITLE,
- ERR_NO_CHANGELOG_DB, 0);
- } else if ( contains8BitChars(mi.m_szChangeLogDbDir) )
- {
- /* make sure the path doesnt contain international characters */
- DSMessageBoxOK(ERR_8BIT_PATH_TITLE, ERR_8BIT_PATH, 0);
- } else if ( 0 == strlen(mi.m_szChangeLogSuffix) )
- {
- DSMessageBoxOK(ERR_NO_CHANGELOG_SUFFIX_TITLE,
- ERR_NO_CHANGELOG_SUFFIX, 0);
- } else if ( !isValidDN(mi.m_szChangeLogSuffix) )
- {
- /* error message displayed by isValidDN */
- }else{
- /* all settings lookg good */
- bValueReturned = FALSE;
- }
- return bValueReturned;
- }
- //////////////////////////////////////////////////////////////////////////////
- // Supplier_Replication_DialogProc
- //
- // ask common settings for this server to be a suppplier
- //
- //
- //
- //
- static BOOL CALLBACK
- Supplier_Replication_DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
- {
- BOOL bValueReturned = FALSE;
- UINT uResult = 0;
- BOOL bResult = FALSE;
- static INT nInitialized = 0;
-
- /* list of controls to be setup for 8bit input/display */
- INT h8bitControls[]={IDC_EDIT_CHANGELOG_DB_DIR,
- IDC_EDIT_CHANGELOG_DB_SUFFIX,
- -1};
- switch (uMsg)
- {
- case WM_INITDIALOG:
- // This message is sent when the property page is first created. Here
- // you can perform any one time initialization that you require.
- Setup8bitInputDisplay(hwndDlg, h8bitControls);
- // need to initialize the changelog dir the first time
- // this dialog is created. This is because
- // the default values are set on dllMain and it wouldn't
- // pick up the users change of target dir to calculate it
- // reason for nInitialized is so it doesn't blow away
- // users changes after leaving module and window is recreated
- // and wm_init is called again
- if( !nInitialized )
- {
- my_snprintf(mi.m_szChangeLogDbDir, sizeof(mi.m_szChangeLogDbDir),"%s\\%s-%s\\%s", TARGETDIR,
- DS_ID_SERVICE, mi.m_szServerIdentifier, DEFAULT_CHANGELOGDIR);
- nInitialized = 1;
- }
- break;
- case WM_COMMAND:
- // Windows sends WM_COMMAND messages whenever the user clicks on
- // a control in your property page. If you need to perform some
- // special action, such as validating data or responding to a
- // button click, do it here.
-
- break;
- case WM_NOTIFY:
- // Windows sends WM_NOTIFY messages to your property page whenever
- // something interesting happens to the page. This could be page
- // activation/deactivation, a button click, etc. The wParam parameter
- // contains a pointer to the property page. The lParam parameter
- // contains a pointer to an NMHDR structure. The code field of this
- // structure contains the notification message code being sent. The
- // property sheet API allows you to alter the behavior of these
- // messages by returning a value for each message. To return a value,
- // use the SetWindowLong Windows SDK function.
- switch (((NMHDR*)lParam)->code)
- {
- case PSN_SETACTIVE:
- // This notification is sent upon activation of the property page.
- // The property sheet should be centered each time it is activated
- // in case the user has moved the stupid thing (this duplicates
- // InstallShield functionality). You should also set the state of
- // the wizard buttons here.
- //
- // NOTE: If you do not wish this page to become active, return -1.
- if( NO_REPLICATION == mi.m_nSetupSupplierReplication)
- {
- /* we dont want to display this page unless this server is a supplier*/
- SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
- return TRUE;
- }
-
- bResult = SetDlgItemText(hwndDlg,
- IDC_EDIT_CHANGELOG_DB_SUFFIX,
- mi.m_szChangeLogSuffix);
- if(FALSE == bResult)
- {
- DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
- }
- bResult = SetDlgItemText(hwndDlg,
- IDC_EDIT_CHANGELOG_DB_DIR,
- mi.m_szChangeLogDbDir);
- if(FALSE == bResult)
- {
- DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
- }
- CenterWindow(GetParent(hwndDlg));
- PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
- break;
- case PSN_KILLACTIVE:
- // This notification is sent upon deactivation of the property page.
- // Here you can do whatever might be necessary for this action, such
- // as saving the state of the controls. You should also reset the
- // the state of the wizard buttons here, as both the Back and Next
- // buttons should be active when you leave the AskOptions function.
- //
- // NOTE: If you do not want the page deactivated, return -1.
- PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
- break;
- case PSN_WIZBACK:
- // The user clicked the back button from the first property page.
- // Set the result code NS_WIZBACK to indicate this action and close
- // the property sheet using brute force. If this procedure is not
- // being used by the first property sheet, you should ignore this
- // notification and simply let windows go to the previous page.
- //
- // NOTE: To prevent the wizard from stepping back, return -1.
- SaveDialogInput_Supplier_Replication(hwndDlg);
- break;
- case PSN_WIZNEXT:
- // The user clicked the next button from the last property page.
- // Set the result code NS_WIZNEXT to indicate this action and close
- // the property sheet using brute force. If this procedure is not
- // being used by the last property sheet, you should ignore this
- // notification and simply let windows go to the next page.
- //
- // NOTE: To prevent the wizard from stepping ahead, return -1.
- SaveDialogInput_Supplier_Replication(hwndDlg);
- if ( FALSE == (bValueReturned = Verify_Supplier_Replication() ) )
- {
- /* all settings look good */
- /* user chose these settings through dialog so use them */
- mi.m_nUseChangeLogSettings = 1;
- }else{
- /* one of the settings is invalid, stay on this page */
- SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
- }
- break;
- case PSN_QUERYCANCEL:
- // This notification is sent when the user clicks the Cancel button.
- // It is also sent in response to the WM_CLOSE messages issued
- // by PSN_WIZBACK and PSN_WIZNEXT. Make sure that we only process
- // this message if the result is not back or next so that we don't
- // nuke the return value assigned by PSN_WIZBACK or PSN_WIZNEXT.
- //
- // NOTE: To prevent the cancel from occuring, return -1.
- if (mi.m_nResult != NS_WIZBACK && mi.m_nResult != NS_WIZNEXT)
- {
- if (QueryExit(hwndDlg))
- {
- mi.m_nResult = NS_WIZCANCEL;
- }
- else
- {
- SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
- bValueReturned = TRUE;
- }
- }
- break;
- }
- break;
- }
- return bValueReturned;
- }
- //////////////////////////////////////////////////////////////////////////////
- // SaveDialogInput_Consumer_DN
- //
- //
- // save input for Consumer DN dialog
- //
- //
- void SaveDialogInput_Consumer_DN(HWND hwndDlg)
- {
- if (1 == mi.m_nConfigConsumerDN)
- {
- GetDlgItemText(hwndDlg,
- IDC_EDIT_CONSUMER_DN,
- mi.m_szConsumerDN,
- MAX_STR_SIZE);
- SaveDialogPasswords(hwndDlg,
- mi.m_szConsumerPW,
- mi.m_szConsumerPWAgain);
- }
- }
- //////////////////////////////////////////////////////////////////////////////
- // Verify_Consumer_DN
- //
- //
- // verify input for Consumer DN dialog
- //
- // Returns TRUE if there is an invalid setting
- // Returns FALSE if all settings are valid
- //
- // SideEffect: displays error (or writes to log in silent mode)
- BOOL Verify_Consumer_DN()
- {
- BOOL bValueReturned = FALSE;
- /* only verify if trying to use these settings */
- if (1 == mi.m_nConfigConsumerDN)
- {
- if ( 0 == strlen(mi.m_szConsumerDN) )
- {
- /* no value entered for consumer dn */
- DSMessageBoxOK(ERR_NO_CONSUMER_DN_TITLE, ERR_NO_CONSUMER_DN, 0);
- bValueReturned = TRUE;
- }else if ( !isValidDN(mi.m_szConsumerDN) )
- {
- /* error message displayed by isvalidDN */
- bValueReturned = TRUE;
- } else
- {
- /* only bother to check passwords if username is valid */
- bValueReturned = VerifyPasswords(mi.m_szConsumerPW,
- mi.m_szConsumerPWAgain,
- SLAPD_MIN_PW_LEN);
- }
- }
- return bValueReturned;
- }
- //////////////////////////////////////////////////////////////////////////////
- // Consumer_DN_DialogProc
- //
- // dialog proc for the Consumer DN page
- // displayed only under Supplier CIR replication
- //
- //
- static BOOL CALLBACK
- Consumer_DN_DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
- {
- BOOL bValueReturned = FALSE;
- UINT uResult = 0;
- BOOL bResult = FALSE;
-
- /* list of controls to be setup for 8bit input/display */
- INT h8bitControls[]={IDC_EDIT_CONSUMER_DN,
- IDC_EDIT_PASSWORD,
- IDC_EDIT_PASSWORD_AGAIN,
- -1};
- switch (uMsg)
- {
- case WM_INITDIALOG:
- // This message is sent when the property page is first created. Here
- // you can perform any one time initialization that you require.
- Setup8bitInputDisplay(hwndDlg, h8bitControls);
- my_snprintf(mi.m_szConsumerDN, sizeof(mi.m_szConsumerDN), "%s,%s", DEFAULT_CONSUMER_DN, mi.m_szInstanceSuffix);
- break;
- case WM_COMMAND:
- // Windows sends WM_COMMAND messages whenever the user clicks on
- // a control in your property page. If you need to perform some
- // special action, such as validating data or responding to a
- // button click, do it here.
- if(BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_RADIO_CONFIG_CONSUMER_DN_YES) )
- {
- EnableConsumerDNFields(hwndDlg, TRUE);
- mi.m_nConfigConsumerDN = 1;
- }else if(BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_RADIO_CONFIG_CONSUMER_DN_NO) ){
- EnableConsumerDNFields(hwndDlg, FALSE);
- mi.m_nConfigConsumerDN = 0;
- }
-
- break;
- case WM_NOTIFY:
- // Windows sends WM_NOTIFY messages to your property page whenever
- // something interesting happens to the page. This could be page
- // activation/deactivation, a button click, etc. The wParam parameter
- // contains a pointer to the property page. The lParam parameter
- // contains a pointer to an NMHDR structure. The code field of this
- // structure contains the notification message code being sent. The
- // property sheet API allows you to alter the behavior of these
- // messages by returning a value for each message. To return a value,
- // use the SetWindowLong Windows SDK function.
- switch (((NMHDR*)lParam)->code)
- {
- case PSN_SETACTIVE:
- // This notification is sent upon activation of the property page.
- // The property sheet should be centered each time it is activated
- // in case the user has moved the stupid thing (this duplicates
- // InstallShield functionality). You should also set the state of
- // the wizard buttons here.
- //
- // NOTE: If you do not wish this page to become active, return -1.
- if( SUPPLIER_CIR_REPLICATION != mi.m_nSetupSupplierReplication )
- {
- /* we only ask consumer dn for supplier cir*/
- SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
- return TRUE;
- }
-
- bResult = SetDlgItemText(hwndDlg,
- IDC_EDIT_CONSUMER_DN,
- mi.m_szConsumerDN);
- if(FALSE == bResult)
- {
- DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
- }
- LoadDialogPasswords(hwndDlg,
- mi.m_szConsumerPW,
- mi.m_szConsumerPWAgain);
- CheckRadioButton(hwndDlg, IDC_RADIO_CONFIG_CONSUMER_DN_YES, IDC_RADIO_CONFIG_CONSUMER_DN_NO,
- ( (1 == mi.m_nConfigConsumerDN) ? IDC_RADIO_CONFIG_CONSUMER_DN_YES :
- IDC_RADIO_CONFIG_CONSUMER_DN_NO));
- if(1 == mi.m_nConfigConsumerDN)
- {
- EnableConsumerDNFields(hwndDlg, TRUE);
- }else{
- EnableConsumerDNFields(hwndDlg, FALSE);
- }
- CenterWindow(GetParent(hwndDlg));
- PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
- break;
- case PSN_KILLACTIVE:
- // This notification is sent upon deactivation of the property page.
- // Here you can do whatever might be necessary for this action, such
- // as saving the state of the controls. You should also reset the
- // the state of the wizard buttons here, as both the Back and Next
- // buttons should be active when you leave the AskOptions function.
- //
- // NOTE: If you do not want the page deactivated, return -1.
- PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
- break;
- case PSN_WIZBACK:
- // The user clicked the back button from the first property page.
- // Set the result code NS_WIZBACK to indicate this action and close
- // the property sheet using brute force. If this procedure is not
- // being used by the first property sheet, you should ignore this
- // notification and simply let windows go to the previous page.
- //
- // NOTE: To prevent the wizard from stepping back, return -1.
- SaveDialogInput_Consumer_DN(hwndDlg);
- break;
- case PSN_WIZNEXT:
- // The user clicked the next button from the last property page.
- // Set the result code NS_WIZNEXT to indicate this action and close
- // the property sheet using brute force. If this procedure is not
- // being used by the last property sheet, you should ignore this
- // notification and simply let windows go to the next page.
- //
- // NOTE: To prevent the wizard from stepping ahead, return -1.
- SaveDialogInput_Consumer_DN(hwndDlg);
- if( TRUE == (bValueReturned = Verify_Consumer_DN(hwndDlg) ) )
- {
- /* one of the settings is invalid, stay on this page */
- SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
- }
-
- break;
- case PSN_QUERYCANCEL:
- // This notification is sent when the user clicks the Cancel button.
- // It is also sent in response to the WM_CLOSE messages issued
- // by PSN_WIZBACK and PSN_WIZNEXT. Make sure that we only process
- // this message if the result is not back or next so that we don't
- // nuke the return value assigned by PSN_WIZBACK or PSN_WIZNEXT.
- //
- // NOTE: To prevent the cancel from occuring, return -1.
- if (mi.m_nResult != NS_WIZBACK && mi.m_nResult != NS_WIZNEXT)
- {
- if (QueryExit(hwndDlg))
- {
- mi.m_nResult = NS_WIZCANCEL;
- }
- else
- {
- SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
- bValueReturned = TRUE;
- }
- }
- break;
- }
- break;
- }
- return bValueReturned;
- }
- //////////////////////////////////////////////////////////////////////////////
- // SetDlgReplDays
- //
- // helper function to convert string to checked days in repl agreement dialog proc
- //
- //
- //
- //
-
- BOOL SetDlgReplDays(HWND hwndDlg,
- PSZ szReplDays)
- {
- INT Days[7] = {0};
- INT i, tmp=0;
- INT DayControls[] ={IDC_CHECK_SUN, IDC_CHECK_MON, IDC_CHECK_TUE,
- IDC_CHECK_WED, IDC_CHECK_THUR, IDC_CHECK_FRI,
- IDC_CHECK_SAT, -1};
- for(i=0; szReplDays != NULL && szReplDays[i] != '\0'; i++)
- {
- tmp = ( (INT) szReplDays[i] ) - ASCII_ZERO;
- if( tmp >= 0 && tmp < 7)
- {
- CheckDlgButton(hwndDlg, DayControls[tmp], BST_CHECKED);
- }
- }
-
- return TRUE;
- }
- //////////////////////////////////////////////////////////////////////////////
- // GetDlgReplDays
- //
- // helper function to convert checked days to string for repl agreement dialog procs
- //
- //
- //
- //
-
- BOOL GetDlgReplDays(HWND hwndDlg,
- PSZ szReplDays)
- {
- INT Days[7] = {0};
- INT i, pos;
- INT DayControls[] ={IDC_CHECK_SUN, IDC_CHECK_MON, IDC_CHECK_TUE,
- IDC_CHECK_WED, IDC_CHECK_THUR, IDC_CHECK_FRI,
- IDC_CHECK_SAT, -1};
- pos=0;
- for(i=0; DayControls[i] != -1; i++)
- {
-
- if( IsDlgButtonChecked(hwndDlg, DayControls[i]) )
- {
- szReplDays[pos]=(char) (i + ASCII_ZERO);
- pos++;
- }
- }
- szReplDays[pos]='\0';
-
- return TRUE;
- }
- //////////////////////////////////////////////////////////////////////////////
- // SetDlgReplTimes
- // Initialize Time Controls/Spinners in ReplAgreementDlgProc
- //
- //
- //
- //
- BOOL SetDlgReplTimes(HWND hwndDlg, PSZ szTimes)
- {
- CHAR s_hh[3]="\0", s_mm[3]="\0";
- CHAR e_hh[3]="\0", e_mm[3]="\0";
- INT i;
-
- for(i=0; i <2; i++)
- {
- s_hh[i] = szTimes[i];
- s_mm[i] = szTimes[i+2];
- e_hh[i] = szTimes[i+5];
- e_mm[i] = szTimes[i+7];
- }
- SetDlgItemText(hwndDlg, IDC_EDIT_REPL_START_TIME_HH, s_hh);
- SetDlgItemText(hwndDlg, IDC_EDIT_REPL_START_TIME_MM, s_mm);
- SetDlgItemText(hwndDlg, IDC_EDIT_REPL_END_TIME_HH, e_hh);
- SetDlgItemText(hwndDlg, IDC_EDIT_REPL_END_TIME_MM, e_mm);
- SendDlgItemMessage(hwndDlg, IDC_SPIN_REPL_START_TIME_HH, UDM_SETBUDDY, (WPARAM)GetDlgItem(hwndDlg, IDC_EDIT_REPL_START_TIME_HH), 0);
- SendDlgItemMessage(hwndDlg, IDC_SPIN_REPL_START_TIME_HH, UDM_SETRANGE, 0, MAKELONG((short)23, (short)0));
- SendDlgItemMessage(hwndDlg, IDC_SPIN_REPL_START_TIME_MM, UDM_SETBUDDY, (WPARAM)GetDlgItem(hwndDlg, IDC_EDIT_REPL_START_TIME_MM), 0);
- SendDlgItemMessage(hwndDlg, IDC_SPIN_REPL_START_TIME_MM, UDM_SETRANGE, 0, MAKELONG((short)59, (short)0));
- SendDlgItemMessage(hwndDlg, IDC_SPIN_REPL_END_TIME_HH, UDM_SETBUDDY, (WPARAM)GetDlgItem(hwndDlg, IDC_EDIT_REPL_END_TIME_HH), 0);
- SendDlgItemMessage(hwndDlg, IDC_SPIN_REPL_END_TIME_HH, UDM_SETRANGE, 0, MAKELONG((short)23, (short)0));
- SendDlgItemMessage(hwndDlg, IDC_SPIN_REPL_END_TIME_MM, UDM_SETBUDDY, (WPARAM)GetDlgItem(hwndDlg, IDC_EDIT_REPL_END_TIME_MM), 0);
- SendDlgItemMessage(hwndDlg, IDC_SPIN_REPL_END_TIME_MM, UDM_SETRANGE, 0, MAKELONG((short)59, (short)0));
-
- return TRUE;
- }
- //////////////////////////////////////////////////////////////////////////////
- // writeTime
- // make Time Component always be 2 digits
- //
- //
- //
- //
- BOOL writeTime(int nn, char *szTime)
- {
- if( nn > 9)
- {
- sprintf(szTime, "%d", nn);
- }else{
- sprintf(szTime, "0%d", nn);
- }
- return TRUE;
- }
- //////////////////////////////////////////////////////////////////////////////
- // GetDlgReplTimes
- // Get Repl Times From the Dialog
- //
- //
- //
- //
- BOOL GetDlgReplTimes(HWND hwndDlg, PSZ szTimes)
- {
- CHAR s_hh[3]="\0", s_mm[3]="\0";
- CHAR e_hh[3]="\0", e_mm[3]="\0";
- INT ns_hh, ns_mm;
- INT ne_hh, ne_mm;
- BOOL bTrans;
- ns_hh = GetDlgItemInt(hwndDlg, IDC_EDIT_REPL_START_TIME_HH, &bTrans, FALSE);
- ns_mm = GetDlgItemInt(hwndDlg, IDC_EDIT_REPL_START_TIME_MM, &bTrans, FALSE);
- ne_hh = GetDlgItemInt(hwndDlg, IDC_EDIT_REPL_END_TIME_HH, &bTrans, FALSE);
- ne_mm = GetDlgItemInt(hwndDlg, IDC_EDIT_REPL_END_TIME_MM, &bTrans, FALSE);
-
- writeTime(ns_hh, s_hh);
- writeTime(ns_mm, s_mm);
- writeTime(ne_hh, e_hh);
- writeTime(ne_mm, e_mm);
- sprintf(szTimes, "%s%s-%s%s", s_hh, s_mm, e_hh, e_mm);
-
- return TRUE;
- }
- //////////////////////////////////////////////////////////////////////////////
- // SaveDlgReplAgreement
- //
- // save information for replication agreements from dialog
- //
- //
- //
- void SaveDlgReplAgreement(HWND hwndDlg,
- PSZ pszReplHost,
- INT *pnReplPort,
- PSZ pszReplRoot,
- PSZ pszReplBindAs,
- PSZ pszReplPw,
- PSZ pszReplDays,
- PSZ pszReplTimes)
- {
- SaveDlgServerInfo(hwndDlg,
- pszReplHost,
- pnReplPort,
- pszReplRoot,
- pszReplBindAs,
- pszReplPw);
- /* get replication days */
- GetDlgReplDays(hwndDlg, pszReplDays);
- /* get replication times */
- GetDlgReplTimes(hwndDlg, pszReplTimes);
- }
- //////////////////////////////////////////////////////////////////////////////
- // LoadDlgReplAgreement
- //
- //load information for replication agreements into dialog
- //
- //
- //
- void LoadDlgReplAgreement(HWND hwndDlg,
- PSZ pszReplHost,
- INT nReplPort,
- PSZ pszReplRoot,
- PSZ pszReplBindAs,
- PSZ pszReplPw,
- PSZ pszReplDays,
- PSZ pszReplTimes)
- {
- LoadDlgServerInfo(hwndDlg,
- pszReplHost,
- nReplPort,
- pszReplRoot,
- pszReplBindAs,
- pszReplPw);
- SetDlgReplDays(hwndDlg, pszReplDays);
-
- /* get replication times */
- SetDlgReplTimes(hwndDlg, pszReplTimes);
- }
- //////////////////////////////////////////////////////////////////////////////
- // VerifyReplAgreement
- //
- // Verify replication agreement
- //
- // Returns TRUE if there is an invalid setting
- // Returns False if all settings are valid
- //
- // SideEffect: displays error (or writes to log in silent mode)
-
- BOOL VerifyReplAgreement( PSZ pszReplHost,
- INT *pnReplPort,
- PSZ pszReplRoot,
- PSZ pszReplBindAs,
- PSZ pszReplPw,
- PSZ pszReplDays,
- PSZ pszReplTimes)
- {
- BOOL bValueReturned = FALSE;
-
- if( TRUE == (bValueReturned = VerifyServerInfo(pszReplHost,
- pnReplPort,
- pszReplRoot,
- pszReplBindAs,
- pszReplPw,
- TRUE) ) )
- {
- /* problem with the server info, just return true for Error */
-
-
- } else if (FALSE == FullyQualifyHostName(pszReplHost) )
- {
- /* can't qualify host name, must be invalid */
- DSMessageBoxOK(ERR_INVALID_HOST_TITLE, ERR_INVALID_HOST,
- pszReplHost, pszReplHost);
- bValueReturned = TRUE;
- } else if (FALSE == UTF8IsValidLdapUser( pszReplHost,
- *pnReplPort,
- pszReplRoot,
- pszReplBindAs,
- pszReplPw,
- FALSE) )
- {
- /* can't bind to host with info entered */
- if( IDNO == DSMessageBox(MB_YESNO, ERR_CANT_FIND_DS_REPL_TITLE,
- ERR_CANT_FIND_DS_REPL, 0, pszReplHost,
- *pnReplPort, pszReplBindAs) )
- {
- /* user wants to stay on this page and fix value, otherwise,
- allows them to continue even though cant find host
- for replication */
- bValueReturned = TRUE;
- }
- }
-
- /* may want to add more verification here */
- return bValueReturned;
- }
- //////////////////////////////////////////////////////////////////////////////
- // Supplier_Replication_Agreement_DialogProc
- //
- // get information for replication agreements
- //
- //
- //
- //
- static BOOL CALLBACK
- Supplier_Replication_Agreement_DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
- {
- BOOL bValueReturned = FALSE;
- UINT uResult = 0;
- BOOL bResult = FALSE;
- HWND hCtrl;
- /* list of controls to be setup for 8bit input/display */
- INT h8bitControls[]={IDC_EDIT_HOST,
- IDC_EDIT_SUFFIX,
- IDC_EDIT_BIND_AS,
- IDC_EDIT_PW,
- -1};
- switch (uMsg)
- {
- case WM_INITDIALOG:
- // This message is sent when the property page is first created. Here
- // you can perform any one time initialization that you require.
- Setup8bitInputDisplay(hwndDlg, h8bitControls);
- break;
- case WM_COMMAND:
- // Windows sends WM_COMMAND messages whenever the user clicks on
- // a control in your property page. If you need to perform some
- // special action, such as validating data or responding to a
- // button click, do it here.
-
- break;
- case WM_NOTIFY:
- // Windows sends WM_NOTIFY messages to your property page whenever
- // something interesting happens to the page. This could be page
- // activation/deactivation, a button click, etc. The wParam parameter
- // contains a pointer to the property page. The lParam parameter
- // contains a pointer to an NMHDR structure. The code field of this
- // structure contains the notification message code being sent. The
- // property sheet API allows you to alter the behavior of these
- // messages by returning a value for each message. To return a value,
- // use the SetWindowLong Windows SDK function.
- switch (((NMHDR*)lParam)->code)
- {
- case PSN_SETACTIVE:
- // This notification is sent upon activation of the property page.
- // The property sheet should be centered each time it is activated
- // in case the user has moved the stupid thing (this duplicates
- // InstallShield functionality). You should also set the state of
- // the wizard buttons here.
- //
- // NOTE: If you do not wish this page to become active, return -1.
- /* stevross: will have to come back to display this twice for middle case */
- if( SUPPLIER_SIR_REPLICATION != mi.m_nSetupSupplierReplication )
- {
- /* we only setup replication agreements for SUPPLIER SIR */
- SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
- return TRUE;
- }
- /* set text to say Supplier Repl Agreement */
- SetDlgItemText(hwndDlg, IDC_STATIC_REPLICATION_AGREEMENT, SUPPLIER_REPL_AGREE);
- /* display values */
- LoadDlgReplAgreement(hwndDlg,
- mi.m_szSupplierHost,
- mi.m_nSupplierPort,
- mi.m_szSupplierRoot,
- mi.m_szSupplierBindAs,
- mi.m_szSupplierPw,
- mi.m_szSIRDays,
- mi.m_szSIRTimes);
-
- /* hide the repl sync interval stuff because it only makes since for CIR */
- hCtrl = GetDlgItem(hwndDlg, IDC_EDIT_REPL_SYNC_INTERVAL);
- ShowWindow(hCtrl,SW_HIDE);
- hCtrl = GetDlgItem(hwndDlg, IDC_STATIC_REPL_SYNC);
- ShowWindow(hCtrl,SW_HIDE);
- hCtrl = GetDlgItem(hwndDlg, IDC_SPIN_REPL_SYNC_INTERVAL);
- ShowWindow(hCtrl,SW_HIDE);
- /* center window n stuff */
- CenterWindow(GetParent(hwndDlg));
- PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
- break;
- case PSN_KILLACTIVE:
- // This notification is sent upon deactivation of the property page.
- // Here you can do whatever might be necessary for this action, such
- // as saving the state of the controls. You should also reset the
- // the state of the wizard buttons here, as both the Back and Next
- // buttons should be active when you leave the AskOptions function.
- //
- // NOTE: If you do not want the page deactivated, return -1.
- PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
- break;
- case PSN_WIZBACK:
- // The user clicked the back button from the first property page.
- // Set the result code NS_WIZBACK to indicate this action and close
- // the property sheet using brute force. If this procedure is not
- // being used by the first property sheet, you should ignore this
- // notification and simply let windows go to the previous page.
- //
- // NOTE: To prevent the wizard from stepping back, return -1.
- SaveDlgReplAgreement(hwndDlg,
- mi.m_szSupplierHost,
- &mi.m_nSupplierPort,
- mi.m_szSupplierRoot,
- mi.m_szSupplierBindAs,
- mi.m_szSupplierPw,
- mi.m_szSIRDays,
- mi.m_szSIRTimes);
- break;
- case PSN_WIZNEXT:
- // The user clicked the next button from the last property page.
- // Set the result code NS_WIZNEXT to indicate this action and close
- // the property sheet using brute force. If this procedure is not
- // being used by the last property sheet, you should ignore this
- // notification and simply let windows go to the next page.
- //
- // NOTE: To prevent the wizard from stepping ahead, return -1.
- /* only bother to check passwords if username is valid */
- SaveDlgReplAgreement(hwndDlg,
- mi.m_szSupplierHost,
- &mi.m_nSupplierPort,
- mi.m_szSupplierRoot,
- mi.m_szSupplierBindAs,
- mi.m_szSupplierPw,
- mi.m_szSIRDays,
- mi.m_szSIRTimes);
- if( TRUE == (bValueReturned = VerifyReplAgreement(mi.m_szSupplierHost,
- &mi.m_nSupplierPort,
- mi.m_szSupplierRoot,
- mi.m_szSupplierBindAs,
- mi.m_szSupplierPw,
- mi.m_szSIRDays,
- mi.m_szSIRTimes) ) )
- {
- /* one of the settings is invalid, stay on this page */
- SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
- }
-
- break;
- case PSN_QUERYCANCEL:
- // This notification is sent when the user clicks the Cancel button.
- // It is also sent in response to the WM_CLOSE messages issued
- // by PSN_WIZBACK and PSN_WIZNEXT. Make sure that we only process
- // this message if the result is not back or next so that we don't
- // nuke the return value assigned by PSN_WIZBACK or PSN_WIZNEXT.
- //
- // NOTE: To prevent the cancel from occuring, return -1.
- if (mi.m_nResult != NS_WIZBACK && mi.m_nResult != NS_WIZNEXT)
- {
- if (QueryExit(hwndDlg))
- {
- mi.m_nResult = NS_WIZCANCEL;
- }
- else
- {
- SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
- bValueReturned = TRUE;
- }
- }
- break;
- }
- break;
- }
- return bValueReturned;
- }
- //////////////////////////////////////////////////////////////////////////////
- // SaveDlgInput_Consumer_Replication_Agreement_DialogProc
- //
- // get info for consumer replication agreements
- //
- //
- //
- //
- void SaveDlgInput_Consumer_Replication_Agreement(HWND hwndDlg)
- {
- BOOL bTrans;
- SaveDlgReplAgreement(hwndDlg,
- mi.m_szConsumerHost,
- &mi.m_nConsumerPort,
- mi.m_szConsumerRoot,
- mi.m_szConsumerBindAs,
- mi.m_szConsumerPw,
- mi.m_szCIRDays,
- mi.m_szCIRTimes);
- /* get the CIR Interval */
- mi.m_nCIRInterval = GetDlgItemInt(hwndDlg, IDC_EDIT_REPL_SYNC_INTERVAL, &bTrans , FALSE);
- }
- //////////////////////////////////////////////////////////////////////////////
- // Consumer_Replication_Agreement_DialogProc
- //
- // get information for replication agreements
- //
- //
- //
- //
- static BOOL CALLBACK
- Consumer_Replication_Agreement_DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
- {
- BOOL bValueReturned = FALSE;
- UINT uResult = 0;
- BOOL bResult = FALSE;
-
- /* list of controls to be setup for 8bit input/display */
- INT h8bitControls[]={IDC_EDIT_HOST,
- IDC_EDIT_SUFFIX,
- IDC_EDIT_BIND_AS,
- IDC_EDIT_PW,
- -1};
- switch (uMsg)
- {
- case WM_INITDIALOG:
- // This message is sent when the property page is first created. Here
- // you can perform any one time initialization that you require.
- Setup8bitInputDisplay(hwndDlg, h8bitControls);
- SendDlgItemMessage(hwndDlg, IDC_SPIN_REPL_SYNC_INTERVAL, UDM_SETBUDDY, (WPARAM)GetDlgItem(hwndDlg, IDC_EDIT_REPL_SYNC_INTERVAL), 0);
- SendDlgItemMessage(hwndDlg, IDC_SPIN_REPL_SYNC_INTERVAL, UDM_SETRANGE, 0, MAKELONG((short)59, (short)0));
- break;
- case WM_COMMAND:
- // Windows sends WM_COMMAND messages whenever the user clicks on
- // a control in your property page. If you need to perform some
- // special action, such as validating data or responding to a
- // button click, do it here.
-
- break;
- case WM_NOTIFY:
- // Windows sends WM_NOTIFY messages to your property page whenever
- // something interesting happens to the page. This could be page
- // activation/deactivation, a button click, etc. The wParam parameter
- // contains a pointer to the property page. The lParam parameter
- // contains a pointer to an NMHDR structure. The code field of this
- // structure contains the notification message code being sent. The
- // property sheet API allows you to alter the behavior of these
- // messages by returning a value for each message. To return a value,
- // use the SetWindowLong Windows SDK function.
- switch (((NMHDR*)lParam)->code)
- {
- case PSN_SETACTIVE:
- // This notification is sent upon activation of the property page.
- // The property sheet should be centered each time it is activated
- // in case the user has moved the stupid thing (this duplicates
- // InstallShield functionality). You should also set the state of
- // the wizard buttons here.
- //
- // NOTE: If you do not wish this page to become active, return -1.
- /* stevross: will have to come back to display this twice for middle case */
- if( CONSUMER_CIR_REPLICATION != mi.m_nSetupConsumerReplication )
- {
- /* we only setup replication agreements for CONSUMER CIR */
- SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
- return TRUE;
- }
- /* make title consumer replication agreement */
- SetDlgItemText(hwndDlg, IDC_STATIC_REPLICATION_AGREEMENT, CONSUMER_REPL_AGREE);
- /* display values */
- LoadDlgReplAgreement(hwndDlg,
- mi.m_szConsumerHost,
- mi.m_nConsumerPort,
- mi.m_szConsumerRoot,
- mi.m_szConsumerBindAs,
- mi.m_szConsumerPw,
- mi.m_szCIRDays,
- mi.m_szCIRTimes);
- SetDlgItemInt(hwndDlg, IDC_EDIT_REPL_SYNC_INTERVAL, mi.m_nCIRInterval, FALSE);
- CenterWindow(GetParent(hwndDlg));
- PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
- break;
- case PSN_KILLACTIVE:
- // This notification is sent upon deactivation of the property page.
- // Here you can do whatever might be necessary for this action, such
- // as saving the state of the controls. You should also reset the
- // the state of the wizard buttons here, as both the Back and Next
- // buttons should be active when you leave the AskOptions function.
- //
- // NOTE: If you do not want the page deactivated, return -1.
- PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
- break;
- case PSN_WIZBACK:
- // The user clicked the back button from the first property page.
- // Set the result code NS_WIZBACK to indicate this action and close
- // the property sheet using brute force. If this procedure is not
- // being used by the first property sheet, you should ignore this
- // notification and simply let windows go to the previous page.
- //
- // NOTE: To prevent the wizard from stepping back, return -1.
- SaveDlgInput_Consumer_Replication_Agreement(hwndDlg);
- break;
- case PSN_WIZNEXT:
- // The user clicked the next button from the last property page.
- // Set the result code NS_WIZNEXT to indicate this action and close
- // the property sheet using brute force. If this procedure is not
- // being used by the last property sheet, you should ignore this
- // notification and simply let windows go to the next page.
- //
- // NOTE: To prevent the wizard from stepping ahead, return -1.
- /* only bother to check passwords if username is valid */
- SaveDlgInput_Consumer_Replication_Agreement(hwndDlg);
- if( TRUE == (bValueReturned = VerifyReplAgreement(mi.m_szConsumerHost,
- &mi.m_nConsumerPort,
- mi.m_szConsumerRoot,
- mi.m_szConsumerBindAs,
- mi.m_szConsumerPw,
- mi.m_szCIRDays,
- mi.m_szCIRTimes) ) )
- {
- /* one of the settings invalid, stay on this page */
- SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
- }
- break;
- case PSN_QUERYCANCEL:
- // This notification is sent when the user clicks the Cancel button.
- // It is also sent in response to the WM_CLOSE messages issued
- // by PSN_WIZBACK and PSN_WIZNEXT. Make sure that we only process
- // this message if the result is not back or next so that we don't
- // nuke the return value assigned by PSN_WIZBACK or PSN_WIZNEXT.
- //
- // NOTE: To prevent the cancel from occuring, return -1.
- if (mi.m_nResult != NS_WIZBACK && mi.m_nResult != NS_WIZNEXT)
- {
- if (QueryExit(hwndDlg))
- {
- mi.m_nResult = NS_WIZCANCEL;
- }
- else
- {
- SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
- bValueReturned = TRUE;
- }
- }
- break;
- }
- break;
- }
- return bValueReturned;
- }
- //////////////////////////////////////////////////////////////////////////////
- // Sample_Entries_Org_DialogProc
- //
- // ask user if they want to populate with sample entries and sample organization
- //
- //
- //
- //
- static BOOL CALLBACK
- Sample_Entries_Org_DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
- {
- BOOL bValueReturned = FALSE;
- UINT uResult = 0;
- BOOL bResult = FALSE;
- CHAR szMustHaveBase[MAX_STR_SIZE]="\0";
- static CHAR szCustomFileName[MAX_STR_SIZE]="\0";
- static CHAR szSampleFileName[MAX_STR_SIZE]="\0";
-
- /* list of controls to be setup for 8bit input/display */
- INT h8bitControls[]={IDC_STATIC_MUST_HAVE_BASE,
- IDC_STATIC_LDIF_FILE_NAME,
- -1};
- switch (uMsg)
- {
- case WM_INITDIALOG:
- // This message is sent when the property page is first created. Here
- // you can perform any one time initialization that you require.
- /* default is to populate with sample entries */
- Setup8bitInputDisplay(hwndDlg, h8bitControls);
- break;
- case WM_COMMAND:
- // Windows sends WM_COMMAND messages whenever the user clicks on
- // a control in your property page. If you need to perform some
- // special action, such as validating data or responding to a
- // button click, do it here.
-
- switch (LOWORD(wParam))
- {
-
- case IDC_BUTTON_CHOOSE_LDIF_FILE:
- GetFileName(hwndDlg, "Choose ldif file to import",
- "Ldif Files|*.ldif|All Files|*.*|",
- NULL, szCustomFileName, MAX_PATH );
-
- /* assume by browsing user will want this file so check custom radio button for them
- and set file to be displayed */
- my_snprintf(mi.m_szPopLdifFile, sizeof(mi.m_szPopLdifFile), "%s", szCustomFileName);
- CheckRadioButton(hwndDlg, IDC_RADIO_DONT_POPULATE, IDC_RADIO_POPULATE_CUSTOM, IDC_RADIO_POPULATE_CUSTOM);
- default:
- mi.m_nPopulateSampleOrg = (int )(BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_CHECK_POPULATE_ORG_ENTRIES ) );
-
- if( BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_RADIO_POPULATE_SAMPLE ) )
- {
- mi.m_nPopulateSampleEntries = 1;
- my_snprintf(mi.m_szPopLdifFile, sizeof(mi.m_szPopLdifFile), "%s", szSampleFileName);
- }else if( BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_RADIO_POPULATE_CUSTOM ) ){
- mi.m_nPopulateSampleEntries = 0;
- mi.m_nPopulateSampleOrg = 1;
- // my_snprintf(mi.m_szPopLdifFile, sizeof(mi.m_szPopLdifFile), "%s", szCustomFileName);
- }else{
- mi.m_nPopulateSampleEntries = 0;
- my_snprintf(mi.m_szPopLdifFile, sizeof(mi.m_szPopLdifFile), "\0");
- }
-
- break;
- }
- /* update ldif file name if changed */
- SetDlgItemText(hwndDlg, IDC_STATIC_LDIF_FILE_NAME, mi.m_szPopLdifFile);
- break;
- case WM_NOTIFY:
- // Windows sends WM_NOTIFY messages to your property page whenever
- // something interesting happens to the page. This could be page
- // activation/deactivation, a button click, etc. The wParam parameter
- // contains a pointer to the property page. The lParam parameter
- // contains a pointer to an NMHDR structure. The code field of this
- // structure contains the notification message code being sent. The
- // property sheet API allows you to alter the behavior of these
- // messages by returning a value for each message. To return a value,
- // use the SetWindowLong Windows SDK function.
- switch (((NMHDR*)lParam)->code)
- {
-
- case PSN_SETACTIVE:
- // This notification is sent upon activation of the property page.
- // The property sheet should be centered each time it is activated
- // in case the user has moved the stupid thing (this duplicates
- // InstallShield functionality). You should also set the state of
- // the wizard buttons here.
- //
- // NOTE: If you do not wish this page to become active, return -1.
- if( (CONSUMER_CIR_REPLICATION == mi.m_nSetupConsumerReplication)
- || (CONSUMER_SIR_REPLICATION == mi.m_nSetupConsumerReplication ) )
- {
- /* we only want to populate if they are not doing CIR */
- SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
- return TRUE;
- }
-
- /* warn user about suffix and database import */
- my_snprintf(szMustHaveBase, sizeof(szMustHaveBase), "(note: must have base %s)", mi.m_szInstanceSuffix );
- SetDlgItemText(hwndDlg, IDC_STATIC_MUST_HAVE_BASE, szMustHaveBase);
- my_snprintf(szSampleFileName, sizeof(szSampleFileName), "%s\\%s", TARGETDIR, SAMPLE_LDIF);
-
- if(mi.m_nExistingUG == 0)
- {
- /* the user is creating a new UG with this instance */
-
- /* create ou=People/ou=Groups */
- // mi.m_nPopulateSampleOrg = 1;
- // lstrcpy(mi.m_szPopLdifFile, SUGGEST_LDIF);
- }
- if(mi.m_nPopulateSampleEntries)
- {
- CheckRadioButton(hwndDlg, IDC_RADIO_DONT_POPULATE,
- IDC_RADIO_POPULATE_CUSTOM,
- IDC_RADIO_POPULATE_SAMPLE);
- } else if (mi.m_szPopLdifFile[0]) {
- CheckRadioButton(hwndDlg, IDC_RADIO_DONT_POPULATE,
- IDC_RADIO_POPULATE_CUSTOM,
- IDC_RADIO_POPULATE_CUSTOM);
- } else {
- CheckRadioButton(hwndDlg, IDC_RADIO_DONT_POPULATE,
- IDC_RADIO_POPULATE_CUSTOM,
- IDC_RADIO_DONT_POPULATE);
- }
- if(mi.m_nPopulateSampleOrg)
- {
- CheckDlgButton(hwndDlg, IDC_CHECK_POPULATE_ORG_ENTRIES, BST_CHECKED);
- }
- SetDlgItemText(hwndDlg, IDC_STATIC_LDIF_FILE_NAME, mi.m_szPopLdifFile);
-
- CenterWindow(GetParent(hwndDlg));
- PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
- break;
- case PSN_KILLACTIVE:
- // This notification is sent upon deactivation of the property page.
- // Here you can do whatever might be necessary for this action, such
- // as saving the state of the controls. You should also reset the
- // the state of the wizard buttons here, as both the Back and Next
- // buttons should be active when you leave the AskOptions function.
- //
- // NOTE: If you do not want the page deactivated, return -1.
- PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
- break;
- case PSN_WIZBACK:
- // The user clicked the back button from the first property page.
- // Set the result code NS_WIZBACK to indicate this action and close
- // the property sheet using brute force. If this procedure is not
- // being used by the first property sheet, you should ignore this
- // notification and simply let windows go to the previous page.
- //
- // NOTE: To prevent the wizard from stepping back, return -1.
-
- /* all settings for this dailog are saved in WM_COMMAND processing */
- break;
- case PSN_WIZNEXT:
- // The user clicked the next button from the last property page.
- // Set the result code NS_WIZNEXT to indicate this action and close
- // the property sheet using brute force. If this procedure is not
- // being used by the last property sheet, you should ignore this
- // notification and simply let windows go to the next page.
- //
- // NOTE: To prevent the wizard from stepping ahead, return -1.
-
- /* all settings for this dailog are saved in WM_COMMAND processing */
- break;
- case PSN_QUERYCANCEL:
- // This notification is sent when the user clicks the Cancel button.
- // It is also sent in response to the WM_CLOSE messages issued
- // by PSN_WIZBACK and PSN_WIZNEXT. Make sure that we only process
- // this message if the result is not back or next so that we don't
- // nuke the return value assigned by PSN_WIZBACK or PSN_WIZNEXT.
- //
- // NOTE: To prevent the cancel from occuring, return -1.
- if (mi.m_nResult != NS_WIZBACK && mi.m_nResult != NS_WIZNEXT)
- {
- if (QueryExit(hwndDlg))
- {
- mi.m_nResult = NS_WIZCANCEL;
- }
- else
- {
- SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
- bValueReturned = TRUE;
- }
- }
- break;
- }
- break;
- }
- return bValueReturned;
- }
- //////////////////////////////////////////////////////////////////////////////
- // Disable_Schema_Checking_DialogProc
- //
- // ask user if they want to disable schema checking
- //
- //
- //
- //
- static BOOL CALLBACK
- Disable_Schema_Checking_DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
- {
- BOOL bValueReturned = FALSE;
- UINT uResult = 0;
- BOOL bResult = FALSE;
-
- switch (uMsg)
- {
- case WM_INITDIALOG:
- // This message is sent when the property page is first created. Here
- // you can perform any one time initialization that you require.
- /* default is to populate with sample entries */
-
- break;
- case WM_COMMAND:
- // Windows sends WM_COMMAND messages whenever the user clicks on
- // a control in your property page. If you need to perform some
- // special action, such as validating data or responding to a
- // button click, do it here.
-
- switch (LOWORD(wParam))
- {
-
- default:
- mi.m_nDisableSchemaChecking = (int )(BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_CHECK_DISABLE_SCHEMA_CHECKING ) );
- break;
- }
- break;
- case WM_NOTIFY:
- // Windows sends WM_NOTIFY messages to your property page whenever
- // something interesting happens to the page. This could be page
- // activation/deactivation, a button click, etc. The wParam parameter
- // contains a pointer to the property page. The lParam parameter
- // contains a pointer to an NMHDR structure. The code field of this
- // structure contains the notification message code being sent. The
- // property sheet API allows you to alter the behavior of these
- // messages by returning a value for each message. To return a value,
- // use the SetWindowLong Windows SDK function.
- switch (((NMHDR*)lParam)->code)
- {
-
- case PSN_SETACTIVE:
- // This notification is sent upon activation of the property page.
- // The property sheet should be centered each time it is activated
- // in case the user has moved the stupid thing (this duplicates
- // InstallShield functionality). You should also set the state of
- // the wizard buttons here.
- //
- // NOTE: If you do not wish this page to become active, return -1.
-
- if(mi.m_nDisableSchemaChecking)
- {
- CheckDlgButton(hwndDlg, IDC_CHECK_DISABLE_SCHEMA_CHECKING, BST_CHECKED);
- }
- CenterWindow(GetParent(hwndDlg));
- PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
- break;
- case PSN_KILLACTIVE:
- // This notification is sent upon deactivation of the property page.
- // Here you can do whatever might be necessary for this action, such
- // as saving the state of the controls. You should also reset the
- // the state of the wizard buttons here, as both the Back and Next
- // buttons should be active when you leave the AskOptions function.
- //
- // NOTE: If you do not want the page deactivated, return -1.
- PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
- break;
- case PSN_WIZBACK:
- // The user clicked the back button from the first property page.
- // Set the result code NS_WIZBACK to indicate this action and close
- // the property sheet using brute force. If this procedure is not
- // being used by the first property sheet, you should ignore this
- // notification and simply let windows go to the previous page.
- //
- // NOTE: To prevent the wizard from stepping back, return -1.
-
- /* all settings for this dailog are saved in WM_COMMAND processing */
- break;
- case PSN_WIZNEXT:
- // The user clicked the next button from the last property page.
- // Set the result code NS_WIZNEXT to indicate this action and close
- // the property sheet using brute force. If this procedure is not
- // being used by the last property sheet, you should ignore this
- // notification and simply let windows go to the next page.
- //
- // NOTE: To prevent the wizard from stepping ahead, return -1.
-
- /* this is the last property page of advanced mode whenever we display it*/
- mi.m_nResult = NS_WIZNEXT;
- SendMessage(GetParent(hwndDlg), WM_CLOSE, 0, 0);
-
- /* all settings for this dailog are saved in WM_COMMAND processing */
- break;
- case PSN_QUERYCANCEL:
- // This notification is sent when the user clicks the Cancel button.
- // It is also sent in response to the WM_CLOSE messages issued
- // by PSN_WIZBACK and PSN_WIZNEXT. Make sure that we only process
- // this message if the result is not back or next so that we don't
- // nuke the return value assigned by PSN_WIZBACK or PSN_WIZNEXT.
- //
- // NOTE: To prevent the cancel from occuring, return -1.
- if (mi.m_nResult != NS_WIZBACK && mi.m_nResult != NS_WIZNEXT)
- {
- if (QueryExit(hwndDlg))
- {
- mi.m_nResult = NS_WIZCANCEL;
- }
- else
- {
- SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
- bValueReturned = TRUE;
- }
- }
- break;
- }
- break;
- }
- return bValueReturned;
- }
- void initialize_module()
- {
- mi.m_nResult = 0;
- mi.m_szMCCBindAs = NULL;
- mi.m_nInstanceServerPort = 0;
- mi.m_nAdminServerPort = 0;
- mi.m_nCfgSspt = 0;
- mi.m_nPopulateSampleEntries = 0;
- mi.m_nPopulateSampleOrg = 1;
- mi.m_nSetupConsumerReplication = 0;
- mi.m_nSetupSupplierReplication = 0;
- mi.m_nMaxChangeLogRecords = 0;
- mi.m_nMaxChangeLogAge = 0;
- mi.m_nChangeLogAgeMagnitude = 0;
- mi.m_nConsumerSSL = 0;
- mi.m_nSupplierSSL = 0;
- mi.m_nUseSupplierSettings = 0;
- mi.m_nUseChangeLogSettings = 0;
- mi.m_nCIRInterval = 0;
- mi.m_nConsumerPort = 0;
- mi.m_nSupplierPort = 0;
- mi.m_nMCCPort = 0;
- mi.m_nExistingMCC = 0;
- mi.m_nUGPort = 0;
- mi.m_nExistingUG = 0;
- mi.m_nDisableSchemaChecking = 0;
- mi.m_nSNMPOn = 0;
- mi.m_nConfigConsumerDN = 0;
- memset(mi.m_szMCCPw, '\0', MAX_STR_SIZE);
- memset(mi.m_szMCCHost, '\0', MAX_STR_SIZE);
- memset(mi.m_szMCCSuffix, '\0', MAX_STR_SIZE);
- memset(mi.m_szUGPw, '\0', MAX_STR_SIZE);
- memset(mi.m_szUGHost, '\0', MAX_STR_SIZE);
- memset(mi.m_szUGSuffix, '\0', MAX_STR_SIZE);
- memset(mi.m_szAdminDomain, '\0', MAX_STR_SIZE);
- memset(mi.m_szLdapURL, '\0', MAX_STR_SIZE);
- memset(mi.m_szUserGroupURL, '\0', MAX_STR_SIZE);
- memset(mi.m_szUserGroupAdmin, '\0', MAX_STR_SIZE);
- memset(mi.m_szUserGroupAdminPW, '\0', MAX_STR_SIZE);
- memset(mi.m_szInstallDN, '\0', MAX_STR_SIZE);
- memset(mi.m_szSsptUid, '\0', MAX_STR_SIZE);
- memset(mi.m_szSsptUidPw, '\0', MAX_STR_SIZE);
- memset(mi.m_szSsptUidPwAgain, '\0', MAX_STR_SIZE);
- memset(mi.m_szSsptUser, '\0', MAX_STR_SIZE);
- memset(mi.m_szServerIdentifier, '\0', MAX_STR_SIZE);
- memset(mi.m_szInstanceSuffix, '\0', MAX_STR_SIZE);
- memset(mi.m_szInstanceUnrestrictedUser, '\0', MAX_STR_SIZE);
- memset(mi.m_szInstancePassword, '\0', MAX_STR_SIZE);
- memset(mi.m_szInstancePasswordAgain, '\0', MAX_STR_SIZE);
- memset(mi.m_szInstanceHostName, '\0', MAX_STR_SIZE);
- memset(mi.m_szSupplierDN, '\0', MAX_STR_SIZE);
- memset(mi.m_szSupplierPW, '\0', MAX_STR_SIZE);
- memset(mi.m_szSupplierPWAgain, '\0', MAX_STR_SIZE);
- memset(mi.m_szSSLClients, '\0', MAX_STR_SIZE);
- memset(mi.m_szChangeLogDbDir, '\0', MAX_STR_SIZE);
- memset(mi.m_szChangeLogSuffix, '\0', MAX_STR_SIZE);
- memset(mi.m_szConsumerDN, '\0', MAX_STR_SIZE);
- memset(mi.m_szConsumerPW, '\0', MAX_STR_SIZE);
- memset(mi.m_szConsumerPWAgain, '\0', MAX_STR_SIZE);
- memset(mi.m_szConsumerHost, '\0', MAX_STR_SIZE);
- memset(mi.m_szConsumerRoot, '\0', MAX_STR_SIZE);
- memset(mi.m_szConsumerBindAs, '\0', MAX_STR_SIZE);
- memset(mi.m_szConsumerPw, '\0', MAX_STR_SIZE);
- memset(mi.m_szSupplierHost, '\0', MAX_STR_SIZE);
- memset(mi.m_szSupplierRoot, '\0', MAX_STR_SIZE);
- memset(mi.m_szSupplierBindAs, '\0', MAX_STR_SIZE);
- memset(mi.m_szSupplierPw, '\0', MAX_STR_SIZE);
- memset(mi.m_szPopLdifFile, '\0', MAX_STR_SIZE);
- memset(mi.m_szCIRDays, '\0', N_DAYS);
- memset(mi.m_szCIRTimes, '\0', N_TIMES);
- memset(mi.m_szSIRDays, '\0', N_DAYS);
- memset(mi.m_szSIRTimes, '\0', N_TIMES);
- }
- //////////////////////////////////////////////////////////////////////////////
- //getSNMPStatus()
- //
- // sets module info for state of SNMPService
- // if its on asks user if ok to turn it off
- // if user says no or there is an error it returns false
- //
- BOOL getSNMPStatus()
- {
- BOOL bReturn = TRUE;
- if ( TRUE == isServiceRunning(SNMP_SERVICE) )
- {
- // its running
- if (SILENTMODE == MODE)
- {
- /* don't prompt user, jsut turn it off */
- if ( 0 == ControlServer(SNMP_SERVICE, FALSE) )
- {
- DSMessageBoxOK(ERR_SNMP_BAD_SHUTDOWN_TITLE,
- ERR_SNMP_BAD_SHUTDOWN, 0);
- bReturn = FALSE;
- }
- mi.m_nSNMPOn = 1;
- } else
- {
- /* ask the user what they want to do */
- if ( IDOK == DSMessageBox(MB_OKCANCEL, ERR_SNMP_IS_RUNNING_TITLE,
- ERR_SNMP_IS_RUNNING, 0) )
- {
- /* save state for later use by cache so we know what to do in post install */
- mi.m_nSNMPOn = 1;
- if ( 0 == ControlServer(SNMP_SERVICE, FALSE) )
- {
- DSMessageBoxOK(ERR_SNMP_BAD_SHUTDOWN_TITLE,
- ERR_SNMP_BAD_SHUTDOWN, 0);
- bReturn = FALSE;
- }
- } else
- {
- UINT uExitCode = 1;
- /* stevross: use ExitProcess until admin server provides us with
- better way to exit framework and cleanup */
- ExitProcess(uExitCode);
- }
- }
- } else
- {
- mi.m_nSNMPOn = 0;
- }
- return bReturn;
- }
- /////////////////////////////////////////////////////////////////
- //
- // somehow determine if slapd is installed under this server root
- //
- //
- BOOL slapdExists(char *pszServerRoot)
- {
- BOOL bReturn = FALSE;
- WIN32_FIND_DATA fileData;
- HANDLE hFileHandle;
- CHAR szCurrentDir[MAX_STR_SIZE]="\0";
- /* not sure what the right way to check is, try this for now */
- /* check if any slapd instances exist in server root */
- /* later look in directory for anything slapd- */
- /* get current dir so we have it for later */
- GetCurrentDirectory(MAX_STR_SIZE, szCurrentDir);
-
- /* change current dir to server root */
- SetCurrentDirectory(pszServerRoot);
- hFileHandle = FindFirstFile("slapd-*", &fileData);
- if( INVALID_HANDLE_VALUE != hFileHandle)
- {
- /* found slapd- something */
- bReturn = TRUE;
- }
- /* set back to previous current directory */
- SetCurrentDirectory(szCurrentDir);
- return bReturn;
- }
- /////////////////////////////////////////////////////////////////
- //
- // turn slapd instances in this server root on or off
- //
- //
- BOOL ControlSlapdServers(char *pszServerRoot, BOOL bOn, BOOL fixPwd)
- {
- BOOL bReturn = FALSE;
- WIN32_FIND_DATA fileData;
- HANDLE hFileHandle;
- CHAR szCurrentDir[MAX_STR_SIZE]="\0";
- /* not sure what the right way to check is, try this for now */
- /* check if any slapd instances exist in server root */
- /* later look in directory for anything slapd- */
- /* get current dir so we have it for later */
- GetCurrentDirectory(MAX_STR_SIZE, szCurrentDir);
-
- /* change current dir to server root */
- SetCurrentDirectory(pszServerRoot);
- hFileHandle = FindFirstFile("slapd-*", &fileData);
- if( INVALID_HANDLE_VALUE != hFileHandle)
- {
- if (fixPwd)
- {
- /* convert password file to new pin format */
- ConvertPasswordToPin(pszServerRoot, fileData.cFileName);
- /* do any server upgrade stuff */
- ReinstallUpgradeServer(pszServerRoot, fileData.cFileName);
- }
-
- /* turn on server */
- ControlSlapdInstance(fileData.cFileName, bOn);
-
- while(TRUE == FindNextFile(hFileHandle, &fileData) )
- {
- if (fixPwd)
- {
- /* convert password file to new pin format */
- ConvertPasswordToPin(pszServerRoot, fileData.cFileName);
- /* do any server upgrade stuff */
- ReinstallUpgradeServer(pszServerRoot, fileData.cFileName);
- }
- /* turn on server */
- ControlSlapdInstance(fileData.cFileName, bOn);
- }
- }
- /* wait to make sure give server enough time startup/shutdown*/
- /* this time should be long enough for all instances we just */
- /* tried to shutdown/startup */
- Sleep(SLAPD_SHUTDOWN_TIME_MILLISECONDS);
- /* set back to previous current directory */
- SetCurrentDirectory(szCurrentDir);
- return bReturn;
- }
- //////////////////////////////////////////////////////////////////////////////
- // TMPL_PreInstall
- //
- // This function is called by the installation framework before asking the
- // user any questions. Here you should determine if all of the requisites
- // for installing this component are being met. If this operation succeeds
- // return TRUE, otherwise display an error message and return FALSE to abort
- // installation.
- //
- BOOL __declspec(dllexport)
- DSINST_PreInstall(LPCSTR lpszInstallPath)
- {
- BOOL bReturn = FALSE;
- // TODO: Add code to check for pre-installation requirements.
- if( TRUE == getSNMPStatus() )
- {
- char * szLdapURL = NULL;
- char * szLdapUser = NULL;
- char * szAdminDomain = NULL;
- getDefaultLdapInfo(TARGETDIR, &szLdapURL, &szLdapUser,
- &szAdminDomain);
- if (szLdapURL && szAdminDomain)
- {
- my_strncpy(mi.m_szLdapURL, szLdapURL, sizeof(mi.m_szLdapURL));
- GetURLComponents(mi.m_szLdapURL, mi.m_szMCCHost,
- &mi.m_nMCCPort, mi.m_szMCCSuffix);
- if (mi.m_szMCCSuffix[0] == 0)
- my_strncpy(mi.m_szMCCSuffix, NS_DOMAIN_ROOT, sizeof(mi.m_szMCCSuffix));
- if (szLdapUser && mi.m_szMCCBindAs)
- my_strncpy(mi.m_szMCCBindAs, szLdapUser, sizeof(mi.m_szMCCBindAs));
- my_strncpy(mi.m_szAdminDomain, szAdminDomain, sizeof(mi.m_szAdminDomain));
- // since this server root is already configured to use
- // an existing configuration directory server, we will
- // not allow the user to install another one here, so
- // the directory server created here will be a user
- // directory; we will still need to ask for the admin
- // user password
- mi.m_nExistingMCC = 1;
- mi.m_nExistingUG = 0;
- mi.m_nCfgSspt = 0;
- // it's only a reinstall if there is already a slapd
- // installed in this server root
- if( slapdExists(TARGETDIR) )
- mi.m_nReInstall = 1;
- else
- mi.m_nReInstall = 0;
- }
- bReturn = TRUE;
- }
- if (mi.m_nReInstall) {
- char infFile[MAX_PATH] = {0};
- my_snprintf(infFile, sizeof(infFile), "%s\\setup\\slapd\\slapd.inf", TARGETDIR);
- GetProductInfoStringWithTok(SETUP_INF_VERSION, "=", oldVersion,
- OLD_VERSION_SIZE, infFile);
- myLogData("file %s old version is %s", infFile, oldVersion);
- }
- return bReturn;
- }
- //////////////////////////////////////////////////////////////////////////////
- // DSINST_AskOptions
- //
- // This function is called by the installation framework to query the user for
- // information about your component. Here you should ask all of the questions
- // required to install your component as a series of wizard property sheets.
- //
- INT __declspec(dllexport)
- DSINST_AskOptions(HWND hwndParent, INT nDirection)
- {
- PROPSHEETPAGE psp[NUM_PROP_PAGES];
- UINT uStartPage;
- INT nNumPages = 0;
- static INT wasExistingMCC = -1;
- // TODO: Initialize a property page for each dialog template/resource
- // required to query the user for options related to your server
- // installation. Don't forget to increment the count of pages contained
- // in NUM_PROP_PAGES at the top of this file.
- /* Keep the value of mi.m_nExistingMCC at the first invocation */
- if (wasExistingMCC == -1)
- {
- wasExistingMCC = mi.m_nExistingMCC;
- }
- /* if in silent mode or reinstalling, don't display any property pages */
- if ( SILENTMODE == MODE )
- {
- mi.m_nResult = nDirection; // keep moving in same direction...
- }else
- {
- if(1 == mi.m_nReInstall)
- {
- uStartPage = ((nDirection == NS_WIZNEXT) ? 0 : 0);
- AddWizardPage(mi.m_hModule, &psp[0], IDD_REINSTALL_CONFIG, ReInstall_DialogProc);
- nNumPages = 1;
- }else{
- if (EXPRESSMODE == MODE)
- {
- /* just ask for Suitespot ID and Unrestricted User */
- uStartPage = ((nDirection == NS_WIZNEXT) ? 0 : 1);
- if (mi.m_nExistingMCC) // just need admin id and pwd
- AddWizardPage(mi.m_hModule, &psp[0], IDD_ADMIN_ID_ONLY,
- Admin_ID_Only_DialogProc);
- else
- AddWizardPage(mi.m_hModule, &psp[0], IDD_SUITESPOTID,
- SuitespotID_DialogProc);
- AddWizardPage(mi.m_hModule, &psp[1], IDD_ROOTDN, RootDN_DialogProc);
- /* make sure to set numprop pages to actual number */
- nNumPages = 2;
- } else if ( (NORMALMODE == MODE) || (CUSTOMMODE == MODE) )
- {
- /* ask for server settings, SuitespotID and Unrestricted User */
- if ((NORMALMODE == MODE) && wasExistingMCC)
- {
- AddWizardPage(mi.m_hModule, &psp[nNumPages++],
- IDD_SERVER_SETTINGS, Server_Settings_DialogProc);
- AddWizardPage(mi.m_hModule, &psp[nNumPages++],
- IDD_ADMIN_ID_ONLY, Admin_ID_Only_DialogProc);
- AddWizardPage(mi.m_hModule, &psp[nNumPages++],
- IDD_ROOTDN, RootDN_DialogProc);
- }
- else
- {
- AddWizardPage(mi.m_hModule, &psp[nNumPages++],
- IDD_MCC_SETTINGS, MCC_Settings_DialogProc);
- AddWizardPage(mi.m_hModule, &psp[nNumPages++],
- IDD_ADMIN_DOMAIN, AdminDomainCustom_DialogProc);
- AddWizardPage(mi.m_hModule, &psp[nNumPages++],
- IDD_MCC_SETTINGS, UG_Settings_DialogProc);
- AddWizardPage(mi.m_hModule, &psp[nNumPages++],
- IDD_SERVER_SETTINGS, Server_Settings_DialogProc);
- AddWizardPage(mi.m_hModule, &psp[nNumPages++],
- IDD_SUITESPOTID, SuitespotID_DialogProc);
- AddWizardPage(mi.m_hModule, &psp[nNumPages++],
- IDD_ADMIN_DOMAIN, AdminDomain_DialogProc);
- AddWizardPage(mi.m_hModule, &psp[nNumPages++],
- IDD_ROOTDN, RootDN_DialogProc);
- }
- /* add additional pages for custom mode */
- if ( (CUSTOMMODE == MODE) )
- {
- #ifdef CUSTOM_REPL_FOR_4X
- AddWizardPage(mi.m_hModule, &psp[nNumPages++],
- IDD_CHOOSE_REPLICATION_SETUP,
- Choose_Replication_DialogProc);
- AddWizardPage(mi.m_hModule, &psp[nNumPages++],
- IDD_SUPPLIER_REPLICATION_SETTINGS,
- Supplier_Replication_DialogProc);
- AddWizardPage(mi.m_hModule, &psp[nNumPages++],
- IDD_CONSUMER_DN, Consumer_DN_DialogProc);
- AddWizardPage(mi.m_hModule, &psp[nNumPages++],
- IDD_REPLICATION_AGREEMENT,
- Supplier_Replication_Agreement_DialogProc);
- AddWizardPage(mi.m_hModule, &psp[nNumPages++],
- IDD_CONSUMER_REPLICATION_SETTINGS,
- Consumer_Replication_DialogProc);
- AddWizardPage(mi.m_hModule, &psp[nNumPages++],
- IDD_REPLICATION_AGREEMENT,
- Consumer_Replication_Agreement_DialogProc);
- #endif
- AddWizardPage(mi.m_hModule, &psp[nNumPages++],
- IDD_SAMPLE_ENTRIES_ORG,
- Sample_Entries_Org_DialogProc);
- AddWizardPage(mi.m_hModule, &psp[nNumPages++],
- IDD_DISABLE_SCHEMA_CHECKING,
- Disable_Schema_Checking_DialogProc);
- }
- uStartPage = ((nDirection == NS_WIZNEXT) ? 0 : (nNumPages-1));
- }
- }
- // Must initialize the result to an error code before calling WizardDialog
- mi.m_nResult = NS_WIZERROR;
- // Set the first page to display based on the direction we are travelling
- // Call WizardDialog to display the set of property pages
- if (WizardDialog(mi.m_hModule, hwndParent, psp, nNumPages, uStartPage) < 0)
- {
- mi.m_nResult = NS_WIZERROR;
- }
- }
- // convert all DN valued attributes to LDAPv3 quoting
- normalizeDNs();
- // store the User directory information
- storeUserDirectoryInfo();
- if (1 == mi.m_nReInstall)
- {
- set_ldap_settings();
- }
- return mi.m_nResult;
- }
- //////////////////////////////////////////////////////////////////////////////
- // DSINST_GetSummary
- //
- // This function is called by the installation framework after all questions,
- // for all components, have been asked. Here you should provide a detailed
- // summary explaining all of the choices selected by the user.
- //
- // IMPORTANT NOTE: Each line MUST end in a carriage return/line feed
- // combination ("\r\n") as this string is placed in an edit control. Edit
- // controls do not properly handle single "\n" end-of-line characters.
- //
- VOID __declspec(dllexport)
- DSINST_GetSummary(LPSTR lpszSummary)
- {
- // TODO: Add code to fill in the summary information entered by the user
- char *psz = lpszSummary;
- /* only use replication settings written to slapd.conf if dialogs were
- seen by user... otherwise set them to null so posted as null */
- if ( 1 != mi.m_nUseSupplierSettings)
- {
- memset(mi.m_szSupplierDN, '\0', MAX_STR_SIZE);
- }
- if ( 1 != mi.m_nUseChangeLogSettings)
- {
- memset(mi.m_szChangeLogDbDir, '\0', MAX_STR_SIZE);
- memset(mi.m_szChangeLogSuffix, '\0', MAX_STR_SIZE);
- }
- if ( 1 != mi.m_nConfigConsumerDN)
- {
- memset(mi.m_szConsumerDN, '\0', MAX_STR_SIZE);
- }
- /* display in order of dialogs */
- if ( 1 == mi.m_nReInstall )
- {
- psz += WriteSummaryStringRC(psz, " %s\r\n", mi.m_hModule, SUM_REINSTALL, NULL);
- } else
- {
- /* if installing into existing configuration directory display settings entered */
- if ( 1 == mi.m_nExistingMCC)
- {
- psz += WriteSummaryStringRC(psz, " %s\r\n", mi.m_hModule, SUM_CONFIG_DS_TITLE, NULL);
- psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_HOST, mi.m_szMCCHost);
- psz += WriteSummaryIntRC(psz, " %s: %d\r\n", mi.m_hModule, SUM_PORT, mi.m_nMCCPort);
- psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_SUFFIX, mi.m_szMCCSuffix);
- psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_BIND_AS, mi.m_szMCCBindAs);
- }
- /* if storing data in existing directory display options entered */
- if ( 1 == mi.m_nExistingUG)
- {
- psz += WriteSummaryStringRC(psz, " %s\r\n", mi.m_hModule, SUM_DATA_DS_TITLE, NULL);
- psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_HOST, mi.m_szUGHost);
- psz += WriteSummaryIntRC(psz, " %s: %d\r\n", mi.m_hModule, SUM_PORT, mi.m_nUGPort);
- psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_SUFFIX, mi.m_szUGSuffix);
- psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_BIND_AS, mi.m_szUserGroupAdmin);
- }
- /* display instance settings */
- psz += WriteSummaryStringRC(psz, " %s\r\n", mi.m_hModule, SUM_DS_SET_TITLE, NULL);
- psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_SERVER_IDENTIFIER, mi.m_szServerIdentifier);
- psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_SUFFIX, mi.m_szInstanceSuffix);
- psz += WriteSummaryIntRC(psz, " %s: %d\r\n", mi.m_hModule, SUM_PORT, mi.m_nInstanceServerPort);
- if ( 1 != mi.m_nExistingMCC)
- {
- /* if not using Existing MCC display configuration Admin id*/
- /* otherwise it is displayed as the Bind As under Configuration Directory */
- psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_CFG_ADM_ID, mi.m_szSsptUid);
- }
- psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_ADMIN_DOMAIN, mi.m_szAdminDomain);
- psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_DIRECTORY_MANAGER, mi.m_szInstanceUnrestrictedUser);
- /* replication settings */
- if (mi.m_nSetupSupplierReplication != NO_REPLICATION)
- {
- psz += WriteSummaryStringRC(psz, " %s\r\n", mi.m_hModule, SUM_SUPPLIER_REPL_TITLE, NULL);
- /* display changelog DB dir and suffix for both supplier replication modes */
- psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_CHANGELOG_DB_DIR, mi.m_szChangeLogDbDir);
- psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_CHANGELOG_SUFFIX, mi.m_szChangeLogSuffix);
- }
- if (SUPPLIER_SIR_REPLICATION == mi.m_nSetupSupplierReplication)
- {
- /* display replication agreement */
- psz += WriteSummaryStringRC(psz, " %s\r\n", mi.m_hModule, SUM_REPL_AGR_TITLE, NULL);
- psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_HOST, mi.m_szSupplierHost);
- psz += WriteSummaryIntRC(psz, " %s: %d\r\n", mi.m_hModule, SUM_PORT, mi.m_nSupplierPort);
- psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_REPL_ROOT, mi.m_szSupplierRoot);
- psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_BIND_AS, mi.m_szSupplierBindAs);
- psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_REPL_DAYS, mi.m_szSIRDays);
- psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_REPL_TIMES, mi.m_szSIRTimes);
- }
- if (SUPPLIER_CIR_REPLICATION == mi.m_nSetupSupplierReplication )
- {
- /* if configuring consumer BIND DN display what user entered */
- if (1 == mi.m_nConfigConsumerDN)
- {
- psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_CONSUMER_BIND_DN, mi.m_szConsumerDN);
- }
- }
- if (CONSUMER_SIR_REPLICATION == mi.m_nSetupConsumerReplication)
- {
- psz += WriteSummaryStringRC(psz, " %s\r\n", mi.m_hModule, SUM_CONSUMER_REPL_TITLE, NULL);
- /* display supplier bind dn */
- psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_SUPPLIER_DN, mi.m_szSupplierDN);
- }
- if (CONSUMER_CIR_REPLICATION == mi.m_nSetupConsumerReplication)
- {
- psz += WriteSummaryStringRC(psz, " %s\r\n", mi.m_hModule, SUM_CONSUMER_REPL_TITLE, NULL);
- /* display replication agreement */
- /* display replication agreement */
- psz += WriteSummaryStringRC(psz, " %s\r\n", mi.m_hModule, SUM_REPL_AGR_TITLE, NULL);
- psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_HOST, mi.m_szConsumerHost);
- psz += WriteSummaryIntRC(psz, " %s: %d\r\n", mi.m_hModule, SUM_PORT, mi.m_nConsumerPort);
- psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_REPL_ROOT, mi.m_szConsumerRoot);
- psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_BIND_AS, mi.m_szConsumerBindAs);
- psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_REPL_DAYS, mi.m_szCIRDays);
- psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_REPL_TIMES, mi.m_szCIRTimes);
- psz += WriteSummaryIntRC(psz, " %s: %d\r\n", mi.m_hModule, SUM_REPL_SYNC_INTERVAL, mi.m_nCIRInterval);
- }
- if ( CUSTOMMODE == MODE)
- {
- /* display org & ldif files */
- psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_POP_ORG_STRUCT, onezero2yesno(mi.m_nPopulateSampleOrg) );
- psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_POP_DB_FILE, mi.m_szPopLdifFile);
- psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_DISABLE_SCHEMA_CHECKING, onezero2yesno(mi.m_nDisableSchemaChecking) );
- }
- }
- *psz = '\0';
- }
- //////////////////////////////////////////////////////////////////////////////
- // DSINST_WriteGlobalCache
- //
- // This function is called by the installation framework when the user clicks
- // Next at the summary screen. Here you should write all information entered
- // by the user into the installation cache for use during silent installation.
- // Data written to this section of the file may be interpreted by the
- // framework. If this operation succeeds return TRUE, otherwise display an
- // error message and return FALSE to indicate an error.
- //
- BOOL __declspec(dllexport)
- DSINST_WriteGlobalCache(LPCSTR lpszCacheFileName, LPCSTR lpszSectionName)
- {
- if(1 == mi.m_nReInstall)
- {
- /* write configuration directory info, thats the only thing we know about */
- /* during reinstall */
- WritePrivateProfileString(lpszSectionName, GLOBAL_INF_LDAP_USER, mi.m_szMCCBindAs,
- lpszCacheFileName);
- WritePrivateProfileString(lpszSectionName, GLOBAL_INF_LDAP_PASSWD, mi.m_szMCCPw,
- lpszCacheFileName);
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_K_LDAP_URL, mi.m_szLdapURL,
- lpszCacheFileName);
- /* where do we get admin domain from on ReInstall ??? is default ok? */
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_ADMIN_DOMAIN, mi.m_szAdminDomain,
- lpszCacheFileName);
- /* shut down all slapd servers so no file conflicts*/
- ControlSlapdServers(TARGETDIR, FALSE, FALSE);
- return TRUE;
- }
- /* this is the first thing called after last dialog, setup UG stuff here if creating UG directory */
- /* stevross: is there a better place to put this ? possibly in GetSummary, */
- /* but what happens in silent mode ?*/
- /* construct the LDAPURL */
- /* suffix must always be o=netscape root */
- my_snprintf(mi.m_szLdapURL, sizeof(mi.m_szLdapURL), "ldap://%s:%d/%s", mi.m_szMCCHost, mi.m_nMCCPort, NS_DOMAIN_ROOT);
- if(mi.m_nExistingUG == 0)
- {
- /* the user is creating a new UG with this instance */
-
- /* create ou=People/ou=Groups */
- // mi.m_nPopulateSampleOrg = 1;
- // lstrcpy(mi.m_szPopLdifFile, SUGGEST_LDIF);
- if(mi.m_nExistingMCC == 0)
- {
- /* the user is also creating a new MCC so set UG admin to MCC admin */
- my_strncpy(mi.m_szUserGroupAdmin, mi.m_szMCCBindAs, sizeof(mi.m_szUserGroupAdmin));
- my_strncpy(mi.m_szUserGroupAdminPW, mi.m_szMCCPw, sizeof(mi.m_szUserGroupAdminPW));
- }else{
- /* user is using an existing MCC so only creating UG, make UG user same as
- Root DN */
- my_strncpy(mi.m_szUserGroupAdmin, mi.m_szInstanceUnrestrictedUser, sizeof(mi.m_szUserGroupAdmin));
- my_strncpy(mi.m_szUserGroupAdminPW, mi.m_szInstancePassword, sizeof(mi.m_szUserGroupAdminPW));
- }
- my_snprintf(mi.m_szUserGroupURL, sizeof(mi.m_szUserGroupURL), "ldap://%s:%d/%s", mi.m_szInstanceHostName,
- mi.m_nInstanceServerPort, mi.m_szInstanceSuffix);
- }
-
- WritePrivateProfileString(lpszSectionName, GLOBAL_INF_LDAP_USER, mi.m_szMCCBindAs,
- lpszCacheFileName);
- WritePrivateProfileString(lpszSectionName, GLOBAL_INF_LDAP_PASSWD, mi.m_szMCCPw,
- lpszCacheFileName);
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_ADMIN_DOMAIN, mi.m_szAdminDomain,
- lpszCacheFileName);
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_K_LDAP_URL, mi.m_szLdapURL,
- lpszCacheFileName);
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_USER_GROUP_LDAP_URL, mi.m_szUserGroupURL,
- lpszCacheFileName);
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_USER_GROUP_ADMIN_ID, mi.m_szUserGroupAdmin,
- lpszCacheFileName);
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_USER_GROUP_ADMIN_PWD, mi.m_szUserGroupAdminPW,
- lpszCacheFileName);
-
- return TRUE;
- }
- //////////////////////////////////////////////////////////////////////////////
- // DSINST_WriteLocalCache
- //
- // This function is called by the installation framework when the user clicks
- // Next at the summary screen. Here you should write all information entered
- // by the user into the installation cache for use during silent installation.
- // Data written to this file is not interpreted by the framework, and may
- // consist of any values that you will need to perform the installation (not
- // just values entered by the user). If this operation succeeds return TRUE,
- // otherwise display an error message and return FALSE to indicate an error.
- //
- BOOL __declspec(dllexport)
- DSINST_WriteLocalCache(LPCSTR lpszCacheFileName, LPCSTR lpszSectionName)
- {
- // TODO: Add code to write data to the cache file (INI format) under the
- // specified section name.
- CHAR szInt[BUFSIZ];
- /* don't want to over write with bogus default values on ReInstall*/
- if(1 == mi.m_nReInstall)
- {
- /* just write snmp status cause thats the only thing we really know*/
- /* will allow to control it on reinstall also */
- WritePrivateProfileString(lpszSectionName, LOCAL_INF_SNMP_ON, onezero2yesno(mi.m_nSNMPOn),
- lpszCacheFileName);
- return TRUE;
- }
-
- /* general settings */
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_USE_EXISTING_MC, onezero2yesno(mi.m_nExistingMCC),
- lpszCacheFileName);
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_USE_EXISTING_UG, onezero2yesno(mi.m_nExistingUG),
- lpszCacheFileName);
- my_snprintf(szInt, sizeof(szInt), "%d", mi.m_nInstanceServerPort);
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_SERVER_PORT, szInt,
- lpszCacheFileName);
-
- if(!mi.m_nExistingUG)
- {
- /* don't write this key when config only directory */
- /* config only directory when using existing data store */
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_SUFFIX, mi.m_szInstanceSuffix,
- lpszCacheFileName);
- }
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_ROOTDN, mi.m_szInstanceUnrestrictedUser,
- lpszCacheFileName);
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_ROOTDNPWD, mi.m_szInstancePassword,
- lpszCacheFileName);
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_SERVER_IDENTIFIER, mi.m_szServerIdentifier,
- lpszCacheFileName);
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_SLAPD_CONFIG_FOR_MC, onezero2yesno(mi.m_nCfgSspt),
- lpszCacheFileName);
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_ADD_SAMPLE_ENTRIES,
- onezero2yesno(mi.m_nPopulateSampleEntries),
- lpszCacheFileName);
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_ADD_ORG_ENTRIES, onezero2yesno(mi.m_nPopulateSampleOrg),
- lpszCacheFileName);
- my_snprintf(szInt, sizeof(szInt), "%s", onezero2yesno( ( (NO_REPLICATION != mi.m_nSetupConsumerReplication) || (NO_REPLICATION != mi.m_nSetupSupplierReplication) ) ) );
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_USE_REPLICATION, szInt,
- lpszCacheFileName);
-
- /* consumer replication settings */
- /* write no instead of number for no replication to be like unix installer */
- if(NO_REPLICATION != mi.m_nSetupConsumerReplication)
- {
- my_snprintf(szInt, sizeof(szInt), "%d", mi.m_nSetupConsumerReplication);
- }else{
- my_snprintf(szInt, sizeof(szInt), "no");
- }
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_SETUP_CONSUMER, szInt,
- lpszCacheFileName);
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_CIR_HOST, mi.m_szConsumerHost,
- lpszCacheFileName);
- my_snprintf(szInt, sizeof(szInt), "%d", mi.m_nConsumerPort );
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_CIR_PORT, szInt,
- lpszCacheFileName);
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_CIR_SUFFIX, mi.m_szConsumerRoot,
- lpszCacheFileName);
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_CIR_BINDDN, mi.m_szConsumerBindAs,
- lpszCacheFileName);
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_CIR_BINDDNPWD, mi.m_szConsumerPw,
- lpszCacheFileName);
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_CIR_SECURITY_ON, onezero2yesno(mi.m_nConsumerSSL),
- lpszCacheFileName);
-
- my_snprintf(szInt, sizeof(szInt), "%d", mi.m_nCIRInterval );
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_CIR_INTERVAL, szInt,
- lpszCacheFileName);
- if(!strcmp(DEFAULT_CIR_DAYS, mi.m_szCIRDays) )
- {
- /* if default of all days write null to inf file as that is what cgi wants */
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_CIR_DAYS, "\0",
- lpszCacheFileName);
- }else{
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_CIR_DAYS, mi.m_szCIRDays,
- lpszCacheFileName);
- }
- if(!strcmp(DEFAULT_CIR_TIMES, mi.m_szCIRTimes) )
- {
- /* if default of all times write null to inf file as that is what cgi wants */
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_CIR_TIMES, "\0",
- lpszCacheFileName);
- }else{
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_CIR_TIMES, mi.m_szCIRTimes,
- lpszCacheFileName);
- }
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_REPLICATIONDN, mi.m_szSupplierDN,
- lpszCacheFileName);
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_REPLICATIONPWD, mi.m_szSupplierPW,
- lpszCacheFileName);
- /* Supplier replication settings */
-
- /* write no instead of number for no replication to be like unix installer */
- if(NO_REPLICATION != mi.m_nSetupSupplierReplication)
- {
- my_snprintf(szInt, sizeof(szInt), "%d", mi.m_nSetupSupplierReplication);
- }else{
- my_snprintf(szInt, sizeof(szInt), "no");
- }
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_SETUP_SUPPLIER, szInt,
- lpszCacheFileName);
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_CHANGELOGDIR, mi.m_szChangeLogDbDir,
- lpszCacheFileName);
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_CHANGELOGSUFFIX, mi.m_szChangeLogSuffix,
- lpszCacheFileName);
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_SIR_HOST, mi.m_szSupplierHost,
- lpszCacheFileName);
- my_snprintf(szInt, sizeof(szInt), "%d", mi.m_nSupplierPort );
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_SIR_PORT, szInt,
- lpszCacheFileName);
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_SIR_SUFFIX, mi.m_szSupplierRoot,
- lpszCacheFileName);
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_SIR_BINDDN, mi.m_szSupplierBindAs,
- lpszCacheFileName);
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_SIR_BINDDNPWD, mi.m_szSupplierPw,
- lpszCacheFileName);
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_SIR_SECURITY_ON, onezero2yesno( mi.m_nSupplierSSL),
- lpszCacheFileName);
-
- if(!strcmp(DEFAULT_SIR_DAYS, mi.m_szSIRDays) )
- {
- /* if default of all days write null to inf file as that is what cgi wants */
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_SIR_DAYS, "\0",
- lpszCacheFileName);
- }else{
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_SIR_DAYS, mi.m_szSIRDays,
- lpszCacheFileName);
- }
- if(!strcmp(DEFAULT_SIR_TIMES, mi.m_szSIRTimes) )
- {
- /* if default of all times write null to inf file as that is what cgi wants */
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_SIR_TIMES, "\0",
- lpszCacheFileName);
- }else{
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_SIR_TIMES, mi.m_szSIRTimes,
- lpszCacheFileName);
- }
- WritePrivateProfileString(lpszSectionName, LOCAL_INF_CONFIG_CONSUMER_DN, onezero2yesno(mi.m_nConfigConsumerDN),
- lpszCacheFileName);
-
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_CONSUMERDN, mi.m_szConsumerDN,
- lpszCacheFileName);
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_CONSUMERPWD, mi.m_szConsumerPW,
- lpszCacheFileName);
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_INSTALL_LDIF_FILE, mi.m_szPopLdifFile,
- lpszCacheFileName);
- WritePrivateProfileString(lpszSectionName, SLAPD_KEY_DISABLE_SCHEMA_CHECKING, onezero2yesno(mi.m_nDisableSchemaChecking),
- lpszCacheFileName);
- WritePrivateProfileString(lpszSectionName, LOCAL_INF_SNMP_ON, onezero2yesno(mi.m_nSNMPOn),
- lpszCacheFileName);
- return TRUE;
- }
- //////////////////////////////////////////////////////////////////////////////
- // DSINST_ReadGlobalCache
- //
- // This function is called by the installation framework during silent install
- // to initialize your data from the cache file you created above. Here you
- // should read any information stored in the installation cache's global
- // section that you need. If this operation succeeds return TRUE, otherwise
- // display an error message and return FALSE to indicate an error.
- //
- BOOL __declspec(dllexport)
- DSINST_ReadGlobalCache(LPCSTR lpszCacheFileName, LPCSTR lpszSectionName)
- {
- // TODO: Add code to read data from the cache file (INI format) under the
- // specified section name.
- /* stevross: this may be null when reading cache for post install or something, so
- make sure to allocate it again */
- CHAR szFormat[MAX_STR_SIZE];
- if(1 == mi.m_nReInstall)
- {
- /* just read config directory stuff */
- /* this is the only stuff we are need and are guaranteed to have */
- LoadString( mi.m_hModule, ERR_READ_GLOBAL_CACHE, szFormat, MAX_STR_SIZE);
-
- GetPrivateProfileString(lpszSectionName, SLAPD_KEY_FULL_MACHINE_NAME, "\0",
- mi.m_szInstanceHostName, MAX_STR_SIZE,
- lpszCacheFileName);
- if (mi.m_szInstanceHostName[0] == 0)
- DSGetHostName(mi.m_szInstanceHostName, MAX_STR_SIZE);
- if(NULL == mi.m_szMCCBindAs )
- {
- mi.m_szMCCBindAs = malloc(MAX_STR_SIZE);
- }
- GetPrivateProfileString(lpszSectionName, GLOBAL_INF_LDAP_USER, "\0",
- mi.m_szMCCBindAs, MAX_STR_SIZE,
- lpszCacheFileName);
- if ( 0 == lstrcmp(mi.m_szMCCBindAs, "\0") )
- {
- DSMessageBoxOK(ERR_NO_SS_ADMIN_TITLE, ERR_NO_SS_ADMIN, 0);
- return FALSE;
- }else{
- /* stevross: now that cgi can handle full DN
- Sspt UID is same user as MCC BindAs no matter what
- look into removing later once get instance creatin working */
- my_strncpy(mi.m_szSsptUid, mi.m_szMCCBindAs, sizeof(mi.m_szSsptUid));
- }
- GetPrivateProfileString(lpszSectionName, GLOBAL_INF_LDAP_PASSWD, "\0",
- mi.m_szMCCPw, MAX_STR_SIZE,
- lpszCacheFileName);
- if ( 0 == lstrcmp(mi.m_szMCCPw, "\0") )
- {
- DSMessageBoxOK(ERR_NO_PW_TITLE, ERR_NO_PW, 0);
- return FALSE;
- }else{
- /* use password for sspt user since this is the ssptuser */
- my_strncpy(mi.m_szSsptUidPw, mi.m_szMCCPw, sizeof(mi.m_szSsptUidPw));
- my_strncpy(mi.m_szSsptUidPwAgain, mi.m_szSsptUidPw, sizeof(mi.m_szSsptUidPwAgain));
- }
- GetPrivateProfileString(lpszSectionName, SLAPD_KEY_ADMIN_DOMAIN, "\0",
- mi.m_szAdminDomain, MAX_STR_SIZE,
- lpszCacheFileName);
- GetPrivateProfileString(lpszSectionName, SLAPD_KEY_K_LDAP_URL, "\0",
- mi.m_szLdapURL, MAX_STR_SIZE,
- lpszCacheFileName);
- if( GetURLComponents(mi.m_szLdapURL, mi.m_szMCCHost,
- &mi.m_nMCCPort, mi.m_szMCCSuffix) != 0)
- {
- DSMessageBoxOK(ERR_NO_CONFIG_URL_TITLE, ERR_NO_CONFIG_URL, 0);
- return FALSE;
- }
- return TRUE;
- }
- LoadString( mi.m_hModule, ERR_READ_GLOBAL_CACHE, szFormat, MAX_STR_SIZE);
-
- GetPrivateProfileString(lpszSectionName, SLAPD_KEY_FULL_MACHINE_NAME, "\0",
- mi.m_szInstanceHostName, MAX_STR_SIZE,
- lpszCacheFileName);
- if (mi.m_szInstanceHostName[0] == 0)
- DSGetHostName(mi.m_szInstanceHostName, MAX_STR_SIZE);
- if(NULL == mi.m_szMCCBindAs )
- {
- mi.m_szMCCBindAs = malloc(MAX_STR_SIZE);
- }
- GetPrivateProfileString(lpszSectionName, GLOBAL_INF_LDAP_USER, "\0",
- mi.m_szMCCBindAs, MAX_STR_SIZE,
- lpszCacheFileName);
- if ( 0 == lstrcmp(mi.m_szMCCBindAs, "\0") )
- {
- DSMessageBoxOK(ERR_NO_SS_ADMIN_TITLE, ERR_NO_SS_ADMIN, 0);
- return FALSE;
- }else{
- /* stevross: now that cgi can handle full DN
- Sspt UID is same user as MCC BindAs no matter what
- look into removing later once get instance creatin working */
- my_strncpy(mi.m_szSsptUid, mi.m_szMCCBindAs, sizeof(mi.m_szSsptUid));
- }
- GetPrivateProfileString(lpszSectionName, GLOBAL_INF_LDAP_PASSWD, "\0",
- mi.m_szMCCPw, MAX_STR_SIZE,
- lpszCacheFileName);
- if ( 0 == lstrcmp(mi.m_szMCCPw, "\0") )
- {
- DSMessageBoxOK(ERR_NO_PW_TITLE, ERR_NO_PW, 0);
- return FALSE;
- }else{
- /* use password for sspt user since this is the ssptuser */
- my_strncpy(mi.m_szSsptUidPw, mi.m_szMCCPw, sizeof(mi.m_szSsptUidPw));
- my_strncpy(mi.m_szSsptUidPwAgain, mi.m_szSsptUidPw, sizeof(mi.m_szSsptUidPwAgain));
- }
- GetPrivateProfileString(lpszSectionName, SLAPD_KEY_ADMIN_DOMAIN, "\0",
- mi.m_szAdminDomain, MAX_STR_SIZE,
- lpszCacheFileName);
- GetPrivateProfileString(lpszSectionName, SLAPD_KEY_K_LDAP_URL, "\0",
- mi.m_szLdapURL, MAX_STR_SIZE,
- lpszCacheFileName);
- if( GetURLComponents(mi.m_szLdapURL, mi.m_szMCCHost,
- &mi.m_nMCCPort, mi.m_szMCCSuffix) != 0)
- {
- DSMessageBoxOK(ERR_NO_CONFIG_URL_TITLE, ERR_NO_CONFIG_URL, 0);
- return FALSE;
- }
- GetPrivateProfileString(lpszSectionName, SLAPD_KEY_USER_GROUP_LDAP_URL, "\0",
- mi.m_szUserGroupURL, MAX_STR_SIZE,
- lpszCacheFileName);
- if( GetURLComponents(mi.m_szUserGroupURL, mi.m_szUGHost,
- &mi.m_nUGPort, mi.m_szUGSuffix) != 0)
- {
- DSMessageBoxOK(ERR_NO_USER_URL_TITLE, ERR_NO_USER_URL, 0);
- return FALSE;
- }
- GetPrivateProfileString(lpszSectionName, SLAPD_KEY_USER_GROUP_ADMIN_ID, "\0",
- mi.m_szUserGroupAdmin, MAX_STR_SIZE,
- lpszCacheFileName);
- GetPrivateProfileString(lpszSectionName, SLAPD_KEY_USER_GROUP_ADMIN_PWD, "\0",
- mi.m_szUserGroupAdminPW, MAX_STR_SIZE,
- lpszCacheFileName);
- return TRUE;
- }
- //////////////////////////////////////////////////////////////////////////////
- // DSINST_ReadLocalCache
- //
- // This function is called by the installation framework during silent install
- // to intialize your data from the local section of the cache created above.
- // Here you should read any information stored in the installation cache's
- // local section that you need. If this operation succeeds return TRUE,
- // otherwise display an error message and return FALSE to indicate an error.
- //
- BOOL __declspec(dllexport)
- DSINST_ReadLocalCache(LPCSTR lpszCacheFileName, LPCSTR lpszSectionName)
- {
- // TODO: Add code to read data from the cache file (INI format) under the
- // specified section name.
- char szTemp[BUFSIZ];
- CHAR szFormat[MAX_STR_SIZE];
- /* only ting we know on this section during reinstall is SNMP value */
- if(1 == mi.m_nReInstall)
- {
-
- GetPrivateProfileString(lpszSectionName, LOCAL_INF_SNMP_ON, "\0",
- szTemp, BUFSIZ,
- lpszCacheFileName);
- mi.m_nSNMPOn = yesno2onezero(szTemp);
- return TRUE;
- }
- LoadString( mi.m_hModule, ERR_READ_LOCAL_CACHE, szFormat, MAX_STR_SIZE);
- GetPrivateProfileString(lpszSectionName, SLAPD_KEY_USE_EXISTING_MC, "\0",
- szTemp, BUFSIZ,
- lpszCacheFileName);
- mi.m_nExistingMCC = yesno2onezero(szTemp);
- GetPrivateProfileString(lpszSectionName, SLAPD_KEY_USE_EXISTING_UG, "\0",
- szTemp, BUFSIZ,
- lpszCacheFileName);
- mi.m_nExistingUG = yesno2onezero(szTemp);
- mi.m_nInstanceServerPort = GetPrivateProfileInt(lpszSectionName,
- SLAPD_KEY_SERVER_PORT, DEFAULT_SERVER_PORT, lpszCacheFileName);
- GetPrivateProfileString(lpszSectionName, SLAPD_KEY_SUFFIX, "\0",
- mi.m_szInstanceSuffix, MAX_STR_SIZE,
- lpszCacheFileName);
-
- GetPrivateProfileString(lpszSectionName, SLAPD_KEY_ROOTDN, "\0",
- mi.m_szInstanceUnrestrictedUser, MAX_STR_SIZE,
- lpszCacheFileName);
-
- GetPrivateProfileString(lpszSectionName, SLAPD_KEY_ROOTDNPWD, "\0",
- mi.m_szInstancePassword, MAX_STR_SIZE,
- lpszCacheFileName);
- my_strncpy(mi.m_szInstancePasswordAgain, mi.m_szInstancePassword, sizeof(mi.m_szInstancePasswordAgain));
- GetPrivateProfileString(lpszSectionName, SLAPD_KEY_SERVER_IDENTIFIER, "\0",
- mi.m_szServerIdentifier, MAX_STR_SIZE,
- lpszCacheFileName);
- GetPrivateProfileString(lpszSectionName, SLAPD_KEY_SLAPD_CONFIG_FOR_MC, "\0",
- szTemp, BUFSIZ,
- lpszCacheFileName);
- mi.m_nCfgSspt = yesno2onezero(szTemp);
- /*stevross: should I add more error checking below? These are only required in certain cases*/
- GetPrivateProfileString(lpszSectionName, SLAPD_KEY_ADD_SAMPLE_ENTRIES, "\0",
- szTemp, BUFSIZ,
- lpszCacheFileName);
- mi.m_nPopulateSampleEntries = yesno2onezero(szTemp);
- GetPrivateProfileString(lpszSectionName, SLAPD_KEY_ADD_ORG_ENTRIES, "\0",
- szTemp, BUFSIZ,
- lpszCacheFileName);
- mi.m_nPopulateSampleOrg = yesno2onezero(szTemp);
- GetPrivateProfileString(lpszSectionName, SLAPD_KEY_SETUP_CONSUMER, "\0",
- szTemp, BUFSIZ,
- lpszCacheFileName);
- /* value should be no, 1 or 2 to be like unix installer*/
- if(!strcmpi(szTemp, "no") )
- {
- mi.m_nSetupConsumerReplication = NO_REPLICATION;
- }else{
- mi.m_nSetupConsumerReplication = GetPrivateProfileInt(lpszSectionName, SLAPD_KEY_SETUP_CONSUMER,
- DEFAULT_SETUP_CONSUMER, lpszCacheFileName);
- }
- GetPrivateProfileString(lpszSectionName, SLAPD_KEY_CIR_HOST, "\0",
- mi.m_szConsumerHost, MAX_STR_SIZE,
- lpszCacheFileName);
- mi.m_nConsumerPort = GetPrivateProfileInt(lpszSectionName, SLAPD_KEY_CIR_PORT,
- DEFAULT_CIR_PORT, lpszCacheFileName);
- GetPrivateProfileString(lpszSectionName, SLAPD_KEY_CIR_SUFFIX, "\0",
- mi.m_szConsumerRoot, MAX_STR_SIZE,
- lpszCacheFileName);
-
- GetPrivateProfileString(lpszSectionName, SLAPD_KEY_CIR_BINDDN, "\0",
- mi.m_szConsumerBindAs, MAX_STR_SIZE,
- lpszCacheFileName);
-
- GetPrivateProfileString(lpszSectionName, SLAPD_KEY_CIR_BINDDNPWD, "\0",
- mi.m_szConsumerPw, MAX_STR_SIZE,
- lpszCacheFileName);
-
- GetPrivateProfileString(lpszSectionName, SLAPD_KEY_CIR_SECURITY_ON, "\0",
- szTemp, BUFSIZ,
- lpszCacheFileName);
- mi.m_nConsumerSSL = yesno2onezero(szTemp);
- mi.m_nCIRInterval = GetPrivateProfileInt(lpszSectionName, SLAPD_KEY_CIR_INTERVAL,
- DEFAULT_CIR_INTERVAL, lpszCacheFileName);
- GetPrivateProfileString(lpszSectionName, SLAPD_KEY_CIR_DAYS, DEFAULT_CIR_DAYS,
- mi.m_szCIRDays, N_DAYS,
- lpszCacheFileName);
- GetPrivateProfileString(lpszSectionName, SLAPD_KEY_CIR_TIMES, DEFAULT_CIR_TIMES,
- mi.m_szCIRTimes, N_TIMES,
- lpszCacheFileName);
-
-
- GetPrivateProfileString(lpszSectionName, SLAPD_KEY_REPLICATIONDN, "\0",
- mi.m_szSupplierDN, MAX_STR_SIZE,
- lpszCacheFileName);
-
- GetPrivateProfileString(lpszSectionName, SLAPD_KEY_REPLICATIONPWD, "\0",
- mi.m_szSupplierPW, MAX_STR_SIZE,
- lpszCacheFileName);
- /* read from cache, so copy it to mi.m_szSupplierPWAgain); */
- my_strncpy(mi.m_szSupplierPWAgain, mi.m_szSupplierPW, sizeof(mi.m_szSupplierPWAgain));
-
- /* Supplier replication settings */
- GetPrivateProfileString(lpszSectionName, SLAPD_KEY_SETUP_SUPPLIER, "\0",
- szTemp, BUFSIZ,
- lpszCacheFileName);
- /* value should be no, 1 or 2 to be like unix installer*/
- if(!strcmpi(szTemp, "no"))
- {
- mi.m_nSetupSupplierReplication = NO_REPLICATION;
- }else{
- mi.m_nSetupSupplierReplication = GetPrivateProfileInt(lpszSectionName, SLAPD_KEY_SETUP_SUPPLIER,
- DEFAULT_SETUP_CONSUMER, lpszCacheFileName);
- }
- GetPrivateProfileString(lpszSectionName, SLAPD_KEY_CHANGELOGDIR, "\0",
- mi.m_szChangeLogDbDir, MAX_STR_SIZE,
- lpszCacheFileName);
-
- GetPrivateProfileString(lpszSectionName, SLAPD_KEY_CHANGELOGSUFFIX, "\0",
- mi.m_szChangeLogSuffix, MAX_STR_SIZE,
- lpszCacheFileName);
- GetPrivateProfileString(lpszSectionName, SLAPD_KEY_SIR_HOST, "\0",
- mi.m_szSupplierHost, MAX_STR_SIZE,
- lpszCacheFileName);
- mi.m_nSupplierPort = GetPrivateProfileInt(lpszSectionName, SLAPD_KEY_SIR_PORT,
- DEFAULT_SIR_PORT, lpszCacheFileName);
- GetPrivateProfileString(lpszSectionName, SLAPD_KEY_SIR_SUFFIX, "\0",
- mi.m_szSupplierRoot, MAX_STR_SIZE,
- lpszCacheFileName);
-
- GetPrivateProfileString(lpszSectionName, SLAPD_KEY_SIR_BINDDN, "\0",
- mi.m_szSupplierBindAs, MAX_STR_SIZE,
- lpszCacheFileName);
-
- GetPrivateProfileString(lpszSectionName, SLAPD_KEY_SIR_BINDDNPWD, "\0",
- mi.m_szSupplierPw, MAX_STR_SIZE,
- lpszCacheFileName);
-
-
- GetPrivateProfileString(lpszSectionName, SLAPD_KEY_SIR_SECURITY_ON, "\0",
- szTemp, BUFSIZ,
- lpszCacheFileName);
- mi.m_nSupplierSSL = yesno2onezero(szTemp);
- GetPrivateProfileString(lpszSectionName, SLAPD_KEY_SIR_DAYS,DEFAULT_SIR_DAYS,
- mi.m_szSIRDays, N_DAYS,
- lpszCacheFileName);
- GetPrivateProfileString(lpszSectionName, SLAPD_KEY_SIR_TIMES, DEFAULT_SIR_TIMES,
- mi.m_szSIRTimes, N_TIMES,
- lpszCacheFileName);
-
- GetPrivateProfileString(lpszSectionName, LOCAL_INF_CONFIG_CONSUMER_DN, "\0",
- szTemp, BUFSIZ,
- lpszCacheFileName);
- mi.m_nConfigConsumerDN = yesno2onezero(szTemp);
- GetPrivateProfileString(lpszSectionName, SLAPD_KEY_CONSUMERDN, "\0",
- mi.m_szConsumerDN, MAX_STR_SIZE,
- lpszCacheFileName);
-
- GetPrivateProfileString(lpszSectionName, SLAPD_KEY_CONSUMERPWD, "\0",
- mi.m_szConsumerPW, MAX_STR_SIZE,
- lpszCacheFileName);
- my_strncpy(mi.m_szConsumerPWAgain, mi.m_szConsumerPW, sizeof(mi.m_szConsumerPWAgain));
-
- GetPrivateProfileString(lpszSectionName, SLAPD_KEY_INSTALL_LDIF_FILE, DEFAULT_INF_POP_LDIF_FILE,
- mi.m_szPopLdifFile, MAX_STR_SIZE,
- lpszCacheFileName);
-
-
- GetPrivateProfileString(lpszSectionName, SLAPD_KEY_DISABLE_SCHEMA_CHECKING, "\0",
- szTemp, BUFSIZ,
- lpszCacheFileName);
- mi.m_nDisableSchemaChecking = yesno2onezero(szTemp);
- GetPrivateProfileString(lpszSectionName, LOCAL_INF_SNMP_ON, "\0",
- szTemp, BUFSIZ,
- lpszCacheFileName);
- mi.m_nSNMPOn = yesno2onezero(szTemp);
- if ( SILENTMODE == MODE)
- {
- /* verify settings here as they didn't get verified in dialog */
- /* stop install if find something bad */
- /* things that always need to be checked */
- if ( Verify_Server_Settings() )
- {
- /* error in server settings */
- return FALSE;
- }
- if ( Verify_ROOTDN() )
- {
- return FALSE;
- }
- #ifdef CUSTOM_REPL_FOR_4X
- if (SUPPLIER_SIR_REPLICATION == mi.m_nSetupSupplierReplication)
- {
- /* always need to check changelogdb and suffix */
- if ( Verify_Supplier_Replication() )
- {
- return FALSE;
- }
-
- /* check replication agreement */
- if ( VerifyReplAgreement(mi.m_szSupplierHost,
- &mi.m_nSupplierPort,
- mi.m_szSupplierRoot,
- mi.m_szSupplierBindAs,
- mi.m_szSupplierPw,
- mi.m_szSIRDays,
- mi.m_szSIRTimes) )
- {
- return FALSE;
- }
- }
- if (SUPPLIER_CIR_REPLICATION == mi.m_nSetupSupplierReplication)
- {
- /* always need to check changelogdb and suffix */
- if ( Verify_Supplier_Replication() )
- {
- return FALSE;
- }
- if ( Verify_Consumer_DN() )
- {
- return FALSE;
- }
- }
- if (CONSUMER_SIR_REPLICATION == mi.m_nSetupConsumerReplication)
- {
- if ( Verify_Consumer_Replication() )
- {
- return FALSE;
- }
- }
- if (CONSUMER_CIR_REPLICATION == mi.m_nSetupConsumerReplication)
- {
- if ( VerifyReplAgreement(mi.m_szConsumerHost,
- &mi.m_nConsumerPort,
- mi.m_szConsumerRoot,
- mi.m_szConsumerBindAs,
- mi.m_szConsumerPw,
- mi.m_szCIRDays,
- mi.m_szCIRTimes) )
- {
- return FALSE;
- }
- }
- #endif
- }
- /* set ldap settings for silent install mode */
- if(1 != mi.m_nReInstall)
- {
- set_ldap_settings();
- }
- return TRUE;
- }
- //////////////////////////////////////////////////////////////////////////////
- // DSINST_ReadComponentInf
- //
- //
- BOOL __declspec(dllexport) DSINST_ReadComponentInf(LPCSTR pszCacheFile, LPCSTR pszSection)
- {
- char szValue[MAX_PATH];
- myLogData("In DSINST_ReadComponentInf: file [%s] section [%s]",
- pszCacheFile, pszSection);
- GetPrivateProfileString(pszSection, SETUP_INF_COM_VENDOR, "", szValue, sizeof(szValue), pszCacheFile);
- cd.szVendor = _strdup(szValue);
- GetPrivateProfileString(pszSection, SETUP_INF_COM_DESC, "", szValue, sizeof(szValue), pszCacheFile);
- cd.szDescription = _strdup(szValue);
- GetPrivateProfileString(pszSection, SETUP_INF_COM_NAME, "", szValue, sizeof(szValue), pszCacheFile);
- cd.szName = _strdup(szValue);
- GetPrivateProfileString(pszSection, SETUP_INF_COM_NICKNAME, "", szValue, sizeof(szValue), pszCacheFile);
- cd.szNickname = _strdup(szValue);
- GetPrivateProfileString(pszSection, SETUP_INF_COM_VERSION, "", szValue, sizeof(szValue), pszCacheFile);
- cd.szVersion = _strdup(szValue);
- GetPrivateProfileString(pszSection, SETUP_INF_COM_BUILDNUMBER, "", szValue, sizeof(szValue), pszCacheFile);
- cd.szBuildNumber = _strdup(szValue);
- GetPrivateProfileString(pszSection, SETUP_INF_COM_REVISION, "", szValue, sizeof(szValue), pszCacheFile);
- cd.szRevision = _strdup(szValue);
- GetPrivateProfileString(pszSection, SETUP_INF_COM_EXPIRY, "", szValue, sizeof(szValue), pszCacheFile);
- cd.szExpireDate = _strdup(szValue);
- GetPrivateProfileString(pszSection, SETUP_INF_COM_SECURITY, "", szValue, sizeof(szValue), pszCacheFile);
- cd.szSecurity = _strdup(szValue);
- cd.szTimeStamp = _strdup(getGMT());
- myLogData("In DSINST_ReadComponentInf: name=%s nick=%s version=%s build=%s "
- "rev=%s time=%s",
- cd.szName, cd.szNickname, cd.szVersion, cd.szBuildNumber, cd.szRevision,
- cd.szTimeStamp);
- return TRUE;
- }
- //////////////////////////////////////////////////////////////////////////////
- // run_cgi
- //
- //
- // runs a cgi
- //
- //
- //
- //
- //
- static int
- run_cgi(const char *serverroot, const char *cgipath, const char *args)
- {
- int status = 0;
- DWORD procResult;
- DWORD dwLastError = 0;
- char prog[MAX_STR_SIZE] = {0};
- char cmdLine[MAX_STR_SIZE] = {0};
- char netsiteRootEnvVar[MAX_STR_SIZE] = {0};
- LPVOID lpMsgBuf;
- my_snprintf(netsiteRootEnvVar, sizeof(netsiteRootEnvVar), "NETSITE_ROOT=%s", serverroot);
- _putenv(netsiteRootEnvVar);
- if ( getenv("DEBUG_DSINST") )
- DebugBreak();
- /* everything is set, start the program */
- my_snprintf(prog, sizeof(prog), "%s\\%s", serverroot, cgipath);
- if (!FileExists(prog))
- {
- lpMsgBuf = getLastErrorMessage();
- DSMessageBoxOK(ERR_NO_FIND_INST_PROG_TITLE,
- ERR_NO_FIND_INST_PROG, 0, prog, lpMsgBuf, LOGFILE);
- status = -1;
- myLogData("Error: could not find program %s: %d (%s)", prog, GetLastError(), lpMsgBuf);
- LocalFree( lpMsgBuf );
- }
- else
- {
- my_snprintf(cmdLine, sizeof(cmdLine), "\"%s\" %s", prog, args);
-
- myLogData("run_cgi: before execution of %s", cmdLine);
- if ( (procResult = _LaunchAndWait(cmdLine, INFINITE)) != 0)
- {
- dwLastError = GetLastError();
- lpMsgBuf = getLastErrorMessage();
- myLogData("Error: could not run %s: %d (%s)", cmdLine, dwLastError, lpMsgBuf);
- if(0 == dwLastError)
- {
- DSMessageBoxOK(ERR_EXEC_INST_PROG_TITLE, ERR_UNK_INST_CREATE, 0,
- prog, LOGFILE);
- }else {
- DSMessageBoxOK(ERR_EXEC_INST_PROG_TITLE, ERR_EXEC_INST_PROG, 0,
- prog, lpMsgBuf, LOGFILE);
- }
-
- LocalFree( lpMsgBuf );
- status = -1;
- }
- myLogData("run_cgi: after execution of %s", cmdLine);
- }
- return status;
- }
- //////////////////////////////////////////////////////////////////////////////
- // create_slapd_instance
- //
- //
- // creates a instance of slapd
- //
- //
- //
- //
- //
- static int
- create_slapd_instance(const char *hostname, const char *serverroot)
- {
- int status = 0;
- char INFfile[MAX_STR_SIZE] = {0};
- char debugFile[MAX_STR_SIZE] = {0};
- struct _stat statbuf;
- static char contentLength[100] = {0};
- static char admservRoot[MAX_STR_SIZE] = {0};
- static char serverUrl[MAX_STR_SIZE] = {0};
- static char scriptName[MAX_STR_SIZE] = {0};
- char szCGIArgs[MAX_STR_SIZE]= {0};
- LPVOID lpMsgBuf;
- /* create an .inf file to pass to index */
- /* write the data to a temp file */
- my_snprintf(INFfile, sizeof(INFfile), "%s\\temp%d.inf", TEMPDIR, _getpid());
- myLogData("create_slapd_instance: inf file is %s", INFfile);
- if (TRUE == (status = writeINFfile(INFfile)) )
- {
- if (status = _stat(INFfile, &statbuf))
- {
- lpMsgBuf = getLastErrorMessage();
- DSMessageBoxOK(ERR_NO_STAT_TMP_FILE_TITLE,
- ERR_NO_STAT_TMP_FILE, 0, INFfile, lpMsgBuf);
- LocalFree(lpMsgBuf);
- }
- else
- {
- /* set temp file for admin output */
- my_snprintf(debugFile, sizeof(debugFile), "DEBUG_FILE=%s\\debug.%d", TEMPDIR, _getpid());
- _putenv(debugFile);
- my_snprintf(szCGIArgs, sizeof(szCGIArgs), "\"%s\\bin\\slapd\\admin\\bin\\Install.pl\"",
- serverroot);
- if (mi.m_nReInstall)
- {
- PL_strcatn(szCGIArgs, sizeof(szCGIArgs), " -r -f ");
- /* add the -r flag if reinstalling */
- } else
- {
- PL_strcatn(szCGIArgs, sizeof(szCGIArgs), " -f ");
- }
- PL_strcatn(szCGIArgs, sizeof(szCGIArgs), "\"");
- PL_strcatn(szCGIArgs, sizeof(szCGIArgs), INFfile);
- PL_strcatn(szCGIArgs, sizeof(szCGIArgs), "\"");
- myLogData("create_slapd_instance: executing %s %s",
- PERL_EXE, szCGIArgs);
- status = run_cgi(serverroot, PERL_EXE, szCGIArgs);
- }
- }
- if (!getenv("USE_LOGFILE"))
- _unlink(INFfile);
- return status;
- }
- //////////////////////////////////////////////////////////////////////////////
- //
- // generate_mcc_bat
- //
- // make bat file with correct classpath, and host/port to start console
- //
- //
- int generate_mcc_bat()
- {
- FILE *fp;
- CHAR szFilename[MAX_STR_SIZE];
- CHAR szJavaDir[MAX_STR_SIZE];
- INT rc = 0;
- // don't generate the file unless asked
- if (!getenv("GENERATE_MCC_BAT")) {
- return rc;
- }
- my_snprintf(szFilename, sizeof(szFilename), "%s\\%s-%s\\mcc.bat", TARGETDIR, DS_ID_SERVICE,
- mi.m_szServerIdentifier);
- fp = fopen(szFilename, "wb");
- if (!fp)
- {
- DSMessageBoxOK(ERR_NO_CREATE_FILE_TITLE,
- ERR_NO_CREATE_FILE, 0, szFilename);
- rc = -1;
- }else{
- my_snprintf(szJavaDir, sizeof(szJavaDir), "%s\\java", TARGETDIR);
-
- fprintf(fp, "pushd \"%s\"\n", szJavaDir);
- /* use jre */
- fprintf(fp, "%s\\jre\\bin\\jre.exe -cp ", TARGETDIR);
-
- /* classes for classpath -cp option on jre */
- fprintf(fp, "%s\\ds50.jar;", szJavaDir);
- fprintf(fp, "%s\\ds50_en.jar;", szJavaDir);
- fprintf(fp, "%s\\admserv45.jar;", szJavaDir);
- fprintf(fp, "%s\\admserv45_en.jar;", szJavaDir);
- fprintf(fp, "%s\\mcc45.jar;", szJavaDir);
- fprintf(fp, "%s\\mcc45_en.jar;", szJavaDir);
- fprintf(fp, "%s\\ldapjdk.jar;", szJavaDir);
- fprintf(fp, "%s\\nmclf45.jar;", szJavaDir);
- fprintf(fp, "%s\\nmclf45_en.jar;", szJavaDir);
- fprintf(fp, "%s\\ssl.zip;", szJavaDir);
- fprintf(fp, "%s\\base.jar;", szJavaDir);
- fprintf(fp, "%s ", szJavaDir);
-
- /* command and arguments to execute the console for this server */
- fprintf(fp, "com.netscape.management.client.console.Console -d %s -p %d -b \"%s\"\n",
- mi.m_szMCCHost, mi.m_nMCCPort, mi.m_szMCCSuffix);
- fprintf(fp, "popd\n");
- fclose(fp);
- rc = 0;
- }
-
- return rc;
- }
- //
- // Generates bat file to install ldap ctrs, since have to be in the same directory to get .h file
- //
- int generate_install_ldapctrs_bat()
- {
- FILE *fp;
- CHAR szFilename[MAX_STR_SIZE];
- INT rc = 0;
- my_snprintf(szFilename, sizeof(szFilename), "%s\\%s", TARGETDIR, INSTALL_CTRS_BAT);
- fp = fopen(szFilename, "wb");
- if (!fp)
- {
- DSMessageBoxOK(ERR_NO_CREATE_FILE_TITLE,
- ERR_NO_CREATE_FILE, 0, szFilename);
- rc = -1;
- }else{
- fprintf(fp, "copy %s\\%s\\nsldapctr*.* %s\n",
- TARGETDIR, BIN_SLAPD_INSTALL_BIN, WINSYSDIR);
- fprintf(fp, "%s\\lodctr nsldapctrs.ini\n", WINSYSDIR);
- fprintf(fp, "del %s\\nsldapctr*.*\n", WINSYSDIR);
- fclose(fp);
- rc = 0;
- }
-
- return rc;
- }
- //--------------------------------------------------------------------------//
- // Install perfmon //
- // Creates Registry keys and loads counters for permon etc //
- //--------------------------------------------------------------------------//
- BOOL _InstallPerfmon(char *szServerRoot)
- {
- BOOL bReturn = FALSE;
- HKEY hKey;
- DWORD dwDisposition;
- char szKey[MAX_PATH];
- char szTemp[MAX_PATH];
- int maxpath = MAX_PATH;
- char *reg = REGSTR_PATH_SERVICES;
- char *id = SVR_ID_SERVICE;
- char *ver = SVR_VERSION;
- char *key = KEY_PERFORMANCE;
- wsprintf(szKey, "%s\\%s%s\\%s", REGSTR_PATH_SERVICES, SVR_ID_SERVICE, SVR_VERSION, KEY_PERFORMANCE);
- if(RegCreateKeyEx(HKEY_LOCAL_MACHINE, szKey, 0, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwDisposition) == ERROR_SUCCESS)
- {
- RegSetValueEx(hKey, "Open", 0, REG_SZ, PERF_OPEN_FUNCTION, lstrlen(PERF_OPEN_FUNCTION)+2);
- RegSetValueEx(hKey, "Collect", 0, REG_SZ, PERF_COLLECT_FUNCTION, lstrlen(PERF_COLLECT_FUNCTION)+2);
- RegSetValueEx(hKey, "Close", 0, REG_SZ, PERF_CLOSE_FUNCTION, lstrlen(PERF_CLOSE_FUNCTION)+2);
- wsprintf(szTemp, "%s\\bin\\slapd\\server\\nsldapctr.dll", szServerRoot);
- RegSetValueEx(hKey, "Library", 0, REG_SZ, szTemp, lstrlen(szTemp)+2);
- RegCloseKey(hKey);
- wsprintf(szTemp, "unlodctr %s%s", SVR_ID_SERVICE, SVR_VERSION);
- _LaunchAndWait(szTemp, INFINITE);
-
- generate_install_ldapctrs_bat();
-
- wsprintf(szTemp, "%s\\%s", szServerRoot, INSTALL_CTRS_BAT);
- _LaunchAndWait(szTemp, INFINITE);
- DeleteFile(szTemp);
-
- }
- return(bReturn);
- }
- static void
- CopyAndDeleteKey(
- HKEY srcBase, const char *srcName,
- HKEY destBase, const char *destName
- )
- {
- DWORD index = 0;
- LONG retval = 0;
- HKEY srcHKEY;
- HKEY destHKEY;
- char className[MAX_PATH+1] = {0};
- DWORD classLen = MAX_PATH+1;
- DWORD nKeys = 0, maxKeyLen = 0, maxClassLen = 0, nValues = 0,
- maxValueNameLen = 0, maxValueDataLen = 0;
- DWORD disposition = 0;
- // open the source key
- retval = RegOpenKey(srcBase, srcName, &srcHKEY);
- if (retval != ERROR_SUCCESS) {
- myLogError("CopyAndDeleteKey: could not open src key %s: ret = %d\n",
- srcName, retval);
- return;
- }
- // get the info from the old key
- retval = RegQueryInfoKey(srcHKEY, className, &classLen, 0, &nKeys, &maxKeyLen,
- &maxClassLen, &nValues, &maxValueNameLen,
- &maxValueDataLen, 0, 0);
- if (retval != ERROR_SUCCESS) {
- myLogError("CopyAndDeleteKey: could not read src key info %s: ret = %d\n",
- srcName, retval);
- return;
- }
- // create the new key based on the info in the old key
- retval = RegCreateKeyEx(destBase, destName, 0, className,
- REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0,
- &destHKEY, &disposition);
- if (retval != ERROR_SUCCESS) {
- myLogError("CopyAndDeleteKey: creating new key %s: ret = %d\n",
- destName, retval);
- return;
- }
- // copy all of the values from the old key to the new key
- for (index = 0; index < nValues; ++index) {
- DWORD valueNameLen = maxValueNameLen+1;
- DWORD valueType = 0;
- DWORD valueDataLen = maxValueDataLen+1;
- char *valueName = calloc(1, valueNameLen);
- char *valueData = calloc(1, valueDataLen);
- retval = RegEnumValue(srcHKEY, index, valueName, &valueNameLen, 0,
- &valueType, valueData, &valueDataLen);
- if (retval == ERROR_SUCCESS) {
- retval = RegSetValueEx(destHKEY, valueName, 0, valueType,
- valueData, valueDataLen);
- if (retval != ERROR_SUCCESS) {
- myLogError("CopyAndDeleteKey: could not write value %s to key %s\n",
- valueName, destName);
- }
- } else {
- myLogError("CopyAndDeleteKey: could not read value %d:%s from key %s\n",
- index, (valueName ? valueName : "null"), destName);
- }
- free(valueName);
- free(valueData);
- }
- // copy all of the sub keys as well; since we're deleting keys as we go along,
- // the actual nKeys will change
- if (nKeys > 0) {
- for (index = nKeys; index; --index) {
- DWORD keyNameLen = maxKeyLen+1;
- char *keyName = calloc(1, keyNameLen);
- retval = RegEnumKey(srcHKEY, index-1, keyName, keyNameLen);
- if (retval == ERROR_SUCCESS) {
- CopyAndDeleteKey(srcHKEY, keyName, destHKEY, keyName);
- } else {
- myLogError("CopyAndDeleteKey: could not get key %d:%s of nKeys %d:"
- "error %d\n", index-1, (keyName ? keyName : "null"),
- nKeys, retval);
- }
- free(keyName);
- }
- }
- // close the destination key
- retval = RegCloseKey(destHKEY);
- if (retval != ERROR_SUCCESS) {
- myLogError("CopyAndDeleteKey: could not close dest key %s\n",
- destName);
- }
- // close the source key
- retval = RegCloseKey(srcHKEY);
- if (retval != ERROR_SUCCESS) {
- myLogError("CopyAndDeleteKey: could not close source key %s\n",
- srcName);
- }
- // delete the source key
- retval = RegDeleteKey(srcBase, srcName);
- if (retval != ERROR_SUCCESS) {
- myLogError("CopyAndDeleteKey: could not delete source key %s\n",
- srcName);
- }
- return;
- }
- // This function will rename the registry keys from the old version to
- // the new version
- static void
- updateRegistryKeys(const char *oldVersion, const char *newVersion)
- {
- char oldKey[MAX_PATH] = {0};
- char newKey[MAX_PATH] = {0};
- int retval = 0;
- DWORD index = 0;
- HKEY svrHKEY;
- DWORD nKeys = 0;
- DWORD maxKeyLen = 0;
- char *ptr = 0;
- // There are three places we need to change
- // the first place is under
- // HKEY_LOCAL_MACHINE\SOFTWARE\Netscape\Directory\oldVersion
- // we need to change oldVersion to newVersion
- my_snprintf(newKey, sizeof(newKey), "%s\\%s", KEY_SOFTWARE_NETSCAPE, SVR_KEY_ROOT);
- strcpy(oldKey, newKey);
- if (ptr = strstr(oldKey, SVR_VERSION)) {
- my_strncpy(ptr, oldVersion, strlen(oldVersion));
- }
- myLogData("updateRegistryKeys: copying %s to %s\n",
- oldKey, newKey);
- CopyAndDeleteKey(HKEY_LOCAL_MACHINE, oldKey, HKEY_LOCAL_MACHINE,
- newKey);
- // the second place is under
- // HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\slapdoldVersoin
- // we need to change oldVersion to newVersion
- my_snprintf(oldKey, sizeof(oldKey), "%s\\%s%s", KEY_SERVICES, PRODUCT_NAME,
- oldVersion);
- my_snprintf(newKey, sizeof(newKey), "%s\\%s%s", KEY_SERVICES, PRODUCT_NAME,
- SVR_VERSION);
- CopyAndDeleteKey(HKEY_LOCAL_MACHINE, oldKey, HKEY_LOCAL_MACHINE,
- newKey);
- // the third place is under
- // HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\slapd-instance
- // for each instance, we need to replace the DisplayName value with
- // the new display name
- // open the services key
- retval = RegOpenKey(HKEY_LOCAL_MACHINE, KEY_SERVICES, &svrHKEY);
-
- // get the info from the key
- retval = RegQueryInfoKey(svrHKEY, 0, 0, 0, &nKeys, &maxKeyLen,
- 0, 0, 0,
- 0, 0, 0);
- if (retval != ERROR_SUCCESS) {
- myLogError("updateRegistryKeys: could not read info %s: ret = %d\n",
- KEY_SERVICES, retval);
- return;
- }
- // iterate the keys under Services
- for (index = 0; index < nKeys; ++index) {
- DWORD keyNameLen = maxKeyLen+1;
- char *keyName = calloc(1, keyNameLen);
- retval = RegEnumKey(svrHKEY, index, keyName, keyNameLen);
- if (retval == ERROR_SUCCESS && keyName &&
- !strncmp(keyName, PRODUCT_NAME, strlen(PRODUCT_NAME))) {
- // read the DisplayName value from the key
- HKEY key;
- retval = RegOpenKey(svrHKEY, keyName, &key);
- if (retval == ERROR_SUCCESS) {
- DWORD type = REG_SZ;
- char oldValue[MAX_PATH+1] = {0};
- DWORD oldValueLen = MAX_PATH+1;
- char *ptr = 0;
- retval = RegQueryValueEx(key, "DisplayName", 0, &type,
- oldValue, &oldValueLen);
- // if the DisplayName contains the old version number . . .
- if ((retval == ERROR_SUCCESS) &&
- (ptr = strstr(oldValue, oldVersion))) {
- // . . . replace it
- strncpy(ptr, SVR_VERSION, strlen(SVR_VERSION));
- retval = RegSetValueEx(key, "DisplayName", 0, type,
- oldValue, oldValueLen);
- if (retval != ERROR_SUCCESS) {
- myLogError("updateRegistryKeys: could not set value %s "
- "for key %s\n",
- oldValue, keyName);
- }
- } else {
- myLogError("updateRegistryKeys: could not read DisplayName"
- "from key %s:%s\n", keyName, oldValue);
- }
- RegCloseKey(key);
- } else {
- myLogError("updateRegistryKeys: could not open service key %s\n",
- keyName);
- }
- } else {
- myLogError("updateRegistryKeys: could not get key %d:%s of nKeys %d:"
- "error %d\n", index, (keyName ? keyName : "null"),
- nKeys, retval);
- }
- free(keyName);
- }
- RegCloseKey(svrHKEY);
- // finally, remove the old Uninstall string
- #define REG_UNINST "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Netscape Server Family 4.0"
- myLogData("Deleting key %s", REG_UNINST);
- DeleteServerRegistryKey(HKEY_LOCAL_MACHINE, REG_UNINST);
- }
- // This function makes sure nsperl is installed and running before the main slapd
- // post install runs, which needs nsperl to run
- static BOOL
- NSPERLINST_PostInstall(VOID)
- {
- BOOL bRC = TRUE;
- char *p = 0;
- char instDir[BUFSIZ] = {0};
- char nsPerlPostInstall[MAX_PATH] = {0};
- char infFile[MAX_PATH] = {0};
- char srcPath[MAX_PATH] = {0};
- char destPath[MAX_PATH] = {0};
- char szCurrentDir[MAX_STR_SIZE] = {0};
- if (GetCurrentDirectory(MAX_STR_SIZE, szCurrentDir) == 0) {
- myLogError("NSPERLINST_PostInstall could not determine the current directory");
- return FALSE;
- }
- // hack to work around potential bug in setupsdk . . .
- SetCurrentDirectory("../slapd");
- my_snprintf(infFile, sizeof(infFile), "slapd.inf");
- GetProductInfoStringWithTok(NSPERL_POST_INSTALL_PROG, "=", nsPerlPostInstall,
- BUFSIZ, infFile);
- p = strrchr(nsPerlPostInstall, '/');
- if (!p)
- p = strrchr(nsPerlPostInstall, '\\');
- if (!p) {
- // punt
- myLogError("NSPERLINST_PostInstall: could not get the post install program %s"
- " from the info file %s", nsPerlPostInstall, infFile);
- return FALSE;
- }
- // get the RunPostInstall attribute from the inf; this is the name
- // of the post install program
- *p = 0; // p points at last dir sep in the path, so null it
- my_snprintf(instDir, sizeof(instDir), "%s\\%s", TARGETDIR, nsPerlPostInstall);
- p++;
- // change directory to the directory of the post install program and
- // execute it
- if (SetCurrentDirectory(instDir) == 0) {
- myLogError("NSPERLINST_PostInstall: could not change directory to %s",
- instDir);
- return FALSE;
- }
- if (_LaunchAndWait(p, INFINITE) != 0) {
- myLogError("NSPERLINST_PostInstall: could not run the nsperl post install"
- " program %s from directory %s", p, instDir);
- SetCurrentDirectory(szCurrentDir);
- return FALSE;
- }
- SetCurrentDirectory(szCurrentDir);
- my_snprintf(srcPath, sizeof(srcPath), "%s\\nsperl.exe", instDir);
- my_snprintf(destPath, sizeof(destPath), "%s\\%s", TARGETDIR, PERL_EXE);
- if (FALSE == CopyFile(srcPath, destPath, FALSE)) { // FALSE to overwrite file if exists
- myLogError("NSPERLINST_PostInstall: could not copy file %s to %s",
- srcPath, destPath);
- bRC = FALSE;
- }
- myLogData("Successfully installed nsPerl");
- return bRC;
- }
- //////////////////////////////////////////////////////////////////////////////
- // DSINST_PostInstall
- //
- // The framework calls this function to perform post-installation
- // configuration. Here you should set values in any product configuration
- // files, install services, add registry keys, start servers, and anything
- // else that can only be done once the binaries are layed down on the disk.
- // If the function succeeds return TRUE, otherwise return FALSE to indicate
- // an error.
- //
- BOOL __declspec(dllexport)
- DSINST_PostInstall(VOID)
- {
- // TODO: Add code to perform configuration.
- BOOL rc;
- myLogData("DSINST_PostInstall: BEGIN");
- rc = NSPERLINST_PostInstall();
-
- /* install perfmon*/
- _InstallPerfmon(TARGETDIR);
- if (1 == mi.m_nReInstall )
- {
- myLogData("DSINST_PostInstall: doing a reinstall");
- /* if the old version is not equal to the new version, we need to
- update the various registry keys */
- if (strcmp(oldVersion, SVR_VERSION)) {
- updateRegistryKeys(oldVersion, SVR_VERSION);
- }
- /* turn servers back on */
- ControlSlapdServers(TARGETDIR, TRUE, TRUE);
-
- /* do any other ReInstall things here */
- }
- /*create slapd instance detects reinstall and calls index with -r */
- myLogData("DSINST_PostInstall: before create_slapd_instance %s", mi.m_szInstanceHostName);
- if (0 == create_slapd_instance(mi.m_szInstanceHostName, TARGETDIR) )
- {
- if ( 0 == generate_mcc_bat() )
- {
- rc = TRUE;
- } else
- {
- DSMessageBoxOK(ERR_CREATE_MCC_BAT_TITLE, ERR_CREATE_MCC_BAT, 0);
- rc = FALSE;
- }
- } else
- {
- DSMessageBoxOK(ERR_CREATE_DS_INSTANCE_TITLE, ERR_CREATE_DS_INSTANCE, 0);
- rc = FALSE;
- }
- /* turn SNMP service back on if it was running */
- if ( 1 == mi.m_nSNMPOn)
- {
- if ( 0 == ControlServer(SNMP_SERVICE, TRUE) )
- {
- /* complain but continue with install */
- DSMessageBoxOK(ERR_SNMP_BAD_STARTUP_TITLE, ERR_SNMP_BAD_STARTUP, 0);
- }
- }
-
- return rc;
- }
- //--------------------------------------------------------------------------//
- // //
- //--------------------------------------------------------------------------//
- static BOOL RemoveSNMPValue(void)
- {
- char line[MAX_PATH];
- char NumValuesBuf[3];
- DWORD Result;
- HKEY hServerKey;
- DWORD NumValues;
- DWORD iterator;
- int value_already_exists = 0;
- DWORD type_buffer;
- char value_data_buffer[MAX_PATH];
- DWORD sizeof_value_data_buffer;
- /* open registry key for Microsoft SNMP service */
- my_snprintf(line, sizeof(line), "%s\\%s", KEY_SERVICES, KEY_SNMP_SERVICE);
- Result = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
- line,
- 0,
- KEY_ALL_ACCESS,
- &hServerKey);
- /* if Microsoft SNMP Service is installed look
- for slapd snmp value to remove */
- if (Result == ERROR_SUCCESS)
- {
- my_snprintf(line, sizeof(line),
- "%s\\%s\\%s",
- KEY_SOFTWARE_NETSCAPE,
- SVR_KEY_ROOT,
- KEY_SNMP_CURRENTVERSION);
- Result = RegQueryInfoKey(hServerKey,
- NULL, NULL,
- NULL, NULL,
- NULL, NULL,
- &NumValues,
- NULL, NULL,
- NULL, NULL);
-
- if (Result == ERROR_SUCCESS)
- {
- for(iterator = 0; iterator <= NumValues; iterator++)
- {
- sizeof_value_data_buffer=MAX_PATH;
- my_snprintf(NumValuesBuf, sizeof(NumValuesBuf), "%d", iterator);
- Result = RegQueryValueEx(hServerKey,
- NumValuesBuf,
- NULL,
- &type_buffer,
- value_data_buffer,
- &sizeof_value_data_buffer);
- if(!lstrcmp(value_data_buffer, line))
- {
- /* remove the value */
- Result = RegDeleteValue(hServerKey, NumValuesBuf);
- break;
- }
- }
- }
- }
- RegCloseKey(hServerKey);
- return (Result == ERROR_SUCCESS);
- }
- BOOL RemoveSNMPKeys(void)
- {
-
- char line[MAX_PATH];
- BOOL bRC = TRUE;
- /* open registry key for Directory SNMP s */
- memset(line, '\0', MAX_PATH);
- my_snprintf(line, sizeof(line), "%s\\%s\\%s", KEY_SOFTWARE_NETSCAPE, SVR_KEY_ROOT,
- KEY_SNMP_CURRENTVERSION);
-
- RegDeleteKey(HKEY_LOCAL_MACHINE, line);
- memset(line, '\0', MAX_PATH);
- my_snprintf(line, sizeof(line), "%s\\%s\\%s", KEY_SOFTWARE_NETSCAPE, SVR_KEY_ROOT,
- SNMP_SERVICE_NAME);
- RegDeleteKey(HKEY_LOCAL_MACHINE, line);
- return bRC;
- }
- BOOL RemovePerfMon(void)
- {
-
- char szTemp[MAX_PATH];
- BOOL bRC = TRUE;
-
- // uninstall perfmon counters and keys
- wsprintf(szTemp, "unlodctr %s%s", SVR_ID_SERVICE, SVR_VERSION);
- _LaunchAndWait(szTemp, 10000);
- wsprintf(szTemp, "%s\\%s%s\\%s", REGSTR_PATH_SERVICES,
- SVR_ID_SERVICE, SVR_VERSION, KEY_PERFORMANCE);
- RegDeleteKey(HKEY_LOCAL_MACHINE, szTemp );
- wsprintf(szTemp, "%s\\%s%s", REGSTR_PATH_SERVICES,
- SVR_ID_SERVICE, SVR_VERSION);
- RegDeleteKey(HKEY_LOCAL_MACHINE, szTemp );
-
- return bRC;
- }
- BOOL RemoveDirectoryRootKey()
- {
- char line[MAX_PATH];
- BOOL bRC = TRUE;
- memset(line, '\0', MAX_PATH);
- my_snprintf(line, sizeof(line), "%s\\%s", KEY_SOFTWARE_NETSCAPE, DS_NAME_SHORT);
- RegDeleteKey(HKEY_LOCAL_MACHINE, line);
-
- return bRC;
- }
- static void
- _PumpMessage(HWND hwndMsgDlg)
- {
- MSG msg;
- while (GetMessage(&msg, NULL, 0, 0))
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- }
- //////////////////////////////////////////////////////////////////////////////
- // ShutdownDialogProc
- //
- // winproc for status window users sees when trying to shutdown instance so
- // install doesn't appear to be hung
- //
- //
- BOOL CALLBACK ShutdownDialogProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
- {
- int retval;
- myLogData("ShutdownDialog Proc iMsg=%d wParam=%d lParam=%d", iMsg, wParam, lParam);
- switch (iMsg)
- {
-
- case WM_INITDIALOG:
- retval = SetWindowText(hwnd, dialogMessage);
- myLogData("19 SetWindowText returns %d", retval);
- if (!retval) myLogError("19 SetWindowText");
- retval = SetDlgItemText(hwnd, IDC_STOPPING_SERVER_MESSAGE,
- dialogMessage);
- myLogData("20 SetDlgItemText returns %d", retval);
- if (!retval) myLogError("20 SetDlgItemText");
- myLogData("iMsg=%d WM_INITDIALOG=%d WM_CREATE=%d msg=%s",
- iMsg, WM_INITDIALOG, WM_CREATE, dialogMessage);
- return TRUE;
-
- case WM_DESTROY:
- PostQuitMessage(0);
- break;
- }
- return FALSE;
- }
- //////////////////////////////////////////////////////////////////////////////
- // shutdownDialog
- //
- // thread proc for creating shutdown dialog acts as win main translating and
- // dispatching events
- //
- //
- void shutdownDialog(ShutdownArg *shutdownargs)
- {
- CHAR dbg[MAX_STR_SIZE]="\0";
- int retval;
- dialogMessage = shutdownargs->pszServiceName;
- myLogData("Before createDialog");
- shutdownargs->hwnd = CreateDialog(mi.m_hModule,
- MAKEINTRESOURCE(IDD_UNINSTALL_STATUS),
- NULL,
- ShutdownDialogProc);
- myLogData("After createDialog");
- if (shutdownargs->hwnd == NULL)
- {
- return;
- }
- CenterWindow(shutdownargs->hwnd);
- retval = SetWindowText(shutdownargs->hwnd, dialogMessage);
- myLogData("1 SetWindowText returns %d", retval);
- retval = GetWindowText(shutdownargs->hwnd, dbg, MAX_STR_SIZE);
- myLogData("GetWindowText string [%s] retval %d", dbg, retval);
- retval = SetDlgItemText(shutdownargs->hwnd, IDC_STOPPING_SERVER_MESSAGE,
- dialogMessage);
- myLogData("3 SetDlgItemText returns %d", retval);
- retval = UpdateWindow(shutdownargs->hwnd);
- myLogData("5 UpdateWindow returns %d", retval);
- retval = ShowWindow(shutdownargs->hwnd, SW_SHOWNORMAL);
- myLogData("6 ShowWindow returns %d", retval);
- retval = UpdateWindow(shutdownargs->hwnd);
- myLogData("7 UpdateWindow returns %d", retval);
- retval = SetWindowText(shutdownargs->hwnd, dialogMessage);
- myLogData("8 SetWindowText returns %d", retval);
- retval = GetWindowText(shutdownargs->hwnd, dbg, MAX_STR_SIZE);
- myLogData("9 GetWindowText string [%s] retval %d", dbg, retval);
- retval = UpdateWindow(shutdownargs->hwnd);
- myLogData("10 retval=%d msg=%s\n", retval, dialogMessage);
- _PumpMessage(shutdownargs->hwnd);
- }
- BOOL writeUninstINFfile(const char *filename,
- const char *pszServerRoot,
- const char *pszServiceName)
- {
- FILE *fp = fopen(filename, "wb");
- CHAR szHostName[MAX_STR_SIZE]="\0";
- DSGetHostName(szHostName, MAX_STR_SIZE);
-
- if (NULL == fp)
- return FALSE;
- // write section header
- fprintf(fp, "[uninstall]\n");
- fprintf(fp, "%s= %s\n", SLAPD_KEY_FULL_MACHINE_NAME, szHostName);
- fprintf(fp, "%s= %s\n", SLAPD_KEY_SERVER_ROOT, pszServerRoot);
- fprintf(fp, "%s= %s\n", SLAPD_KEY_SERVER_IDENTIFIER, pszServiceName);
- fprintf(fp, "%s= %s\n", GLOBAL_INF_LDAP_HOST, GetLdapHost() );
- fprintf(fp, "%s= %d\n", GLOBAL_INF_LDAP_PORT, GetLdapPort() );
- fprintf(fp, "%s= %s\n", SLAPD_KEY_SUFFIX, GetLdapSuffix() );
- fprintf(fp, "%s= %s\n", SLAPD_KEY_SERVER_ADMIN_ID, GetLdapUser() );
- fprintf(fp, "%s= %s\n", SLAPD_KEY_SERVER_ADMIN_PWD, GetLdapPassword() );
- fprintf(fp, "%s= %s\n", SLAPD_INSTALL_LOG_FILE_NAME, LOGFILE );
-
- fclose(fp);
- return TRUE;
- }
- //////////////////////////////
- //
- // try to turn a server instance on or off
- // displays dialog while doing so
- //
- //
- void ControlSlapdInstance(char *pszServiceName, BOOL bOn)
- {
- INT shutdown_tries=0;
- BOOL bServerRunning=0;
- CHAR szLog[MAX_STR_SIZE]="\0";
- CHAR szFormat[MAX_STR_SIZE]="\0";
- ShutdownArg shutdownargs;
- CHAR szMessage[MAX_STR_SIZE]="\0";
- const CHAR *shortName = getShortName(pszServiceName);
- myLogData("Begin ControlSlapdInstance");
- if(bOn)
- {
- LoadString( mi.m_hModule, IDS_STARTING_SERVICE, szFormat, MAX_STR_SIZE);
- }else{
- LoadString( mi.m_hModule, IDS_STOPPING_SERVICE, szFormat, MAX_STR_SIZE);
- }
- my_snprintf(szMessage, sizeof(szMessage), szFormat, shortName);
- myLogData(szMessage);
- ZeroMemory(&shutdownargs, sizeof(shutdownargs));
- /* strategy here is to try and turn on/off the server,
- sometimes it may take more than the first try
- if can't do it after N tries then give up
- and warn user */
- /* check for opposite of bOn (ie starting server bOn = true, check if its down = false) */
- while ( shutdown_tries < MAX_SLAPD_SHUTDOWN_TRIES
- && (bOn != (bServerRunning = isServiceRunning( pszServiceName ) ) ) )
- {
- /* try to turn of the server */
- my_snprintf(szLog, sizeof(szLog), szMessage);
- LogData(NULL, szLog);
- myLogData(szLog);
- /* setup and launch thread to display window to user
- so it doesn't think install is hung */
- shutdownargs.pszServiceName = szMessage;
- _beginthread(shutdownDialog, 0, &shutdownargs);
- ControlServer( pszServiceName, bOn );
- /* give it some time to shutdown */
- /* unneeded? */
-
- if(bOn)
- {
- LoadString( mi.m_hModule, IDS_WAIT_SERVICE_START, szFormat, MAX_STR_SIZE);
- }else{
- LoadString( mi.m_hModule, IDS_WAIT_SERVICE_STOP, szFormat, MAX_STR_SIZE);
- }
- my_snprintf(szLog, sizeof(szLog), szFormat, shortName);
- LogData(NULL, szLog);
- myLogData(szLog);
- Sleep(SLAPD_SHUTDOWN_TIME_MILLISECONDS);
- shutdown_tries++;
- }
- if ((shutdown_tries > 0) && (shutdownargs.hwnd > 0))
- {
- SendMessage(shutdownargs.hwnd, WM_DESTROY, 0, 0);
- }
- if ( MAX_SLAPD_SHUTDOWN_TRIES == shutdown_tries)
- {
- /* check if it got it the last time */
- /* it should be whatever user wanted in bOn at this point*/
- if (bOn == (bServerRunning = isServiceRunning( pszServiceName ) ) )
- {
- /* warn user, ask if they want to continue */
- if ( IDOK == DSMessageBox(MB_OKCANCEL, ERR_SLAPD_SHUTDOWN_TITLE,
- ERR_SLAPD_SHUTDOWN, shortName, shortName) )
- {
- } else
- {
- UINT uExitCode = 1;
- /* stevross: use ExitProcess until admin server provides us with
- better way to exit framework and cleanup */
- ExitProcess(uExitCode);
- }
- }
- }
- myLogData("End ControlSlapdInstance");
- }
- static void ConvertPasswordToPin(char *pszServerRoot, char *pszServiceName)
- {
- CHAR szFormat[MAX_STR_SIZE*4]="\0";
- CHAR szCurrentDir[MAX_STR_SIZE]="\0";
- CHAR szNewDir[MAX_STR_SIZE]="\0";
- myLogData("Begin ConvertPasswordToPin");
- /* get current dir so we have it for later */
- if (GetCurrentDirectory(MAX_STR_SIZE, szCurrentDir) == 0)
- {
- myLogData("ConvertPasswordToPin: could not get current directory: %d",
- GetLastError());
- return;
- }
- /* have to be in the alias directory to run this */
- my_snprintf(szNewDir, sizeof(szNewDir), "%s\\alias", pszServerRoot);
- /* change current dir to the alias directory */
- if (SetCurrentDirectory(szNewDir) == 0)
- {
- myLogData("ConvertPasswordToPin: could not set current directory to %s: %d",
- szNewDir, GetLastError());
- return;
- }
- /* spawn the perl script which does the conversion */
- my_snprintf(szFormat, sizeof(szFormat), "\"%s\\bin\\slapd\\admin\\bin\\migratePwdFile\" \"%s\" %s",
- pszServerRoot, pszServerRoot, pszServiceName);
- run_cgi(pszServerRoot, PERL_EXE, szFormat);
- if (SetCurrentDirectory(szCurrentDir) == 0)
- {
- myLogData("ConvertPasswordToPin: could not set current directory back to %s: %d",
- szCurrentDir, GetLastError());
- return;
- }
-
- myLogData("End ConvertPasswordToPin");
- }
- static void ReinstallUpgradeServer(char *pszServerRoot, char *pszServiceName)
- {
- CHAR szFormat[MAX_STR_SIZE*4]="\0";
- CHAR szCurrentDir[MAX_STR_SIZE]="\0";
- myLogData("Begin ReinstallUpgradeServer");
- /* get current dir so we have it for later */
- if (GetCurrentDirectory(MAX_STR_SIZE, szCurrentDir) == 0)
- {
- myLogData("ReinstallUpgradeServer: could not get current directory: %d",
- GetLastError());
- return;
- }
- /* have to be in the server root directory to run this */
- if (SetCurrentDirectory(pszServerRoot) == 0)
- {
- myLogData("ReinstallUpgradeServer: could not set current directory to %s: %d",
- pszServerRoot, GetLastError());
- return;
- }
- /* spawn the perl script which does the conversion */
- my_snprintf(szFormat, sizeof(szFormat), "\"%s\\bin\\slapd\\admin\\bin\\upgradeServer\" \"%s\" %s",
- pszServerRoot, pszServerRoot, pszServiceName);
- run_cgi(pszServerRoot, PERL_EXE, szFormat);
- if (SetCurrentDirectory(szCurrentDir) == 0)
- {
- myLogData("ReinstallUpgradeServer: could not set current directory back to %s: %d",
- szCurrentDir, GetLastError());
- return;
- }
-
- myLogData("End ReinstallUpgradeServer");
- }
- BOOL RemoveSlapdInstance(LPCSTR pszServerRoot, char *pszServiceName)
- {
- int status = 0;
- char szINFfile[MAX_STR_SIZE] = "\0";
- CHAR szCGIArgs[MAX_STR_SIZE]="\0";
- /* try to turn of service */
- ControlSlapdInstance(pszServiceName, FALSE);
- /* now try to remove the instance */
- /* call remove cgi with inf */
- my_snprintf(szINFfile, sizeof(szINFfile), "%s/unin%d.inf", TEMPDIR, _getpid());
- writeUninstINFfile( szINFfile, pszServerRoot, pszServiceName);
- my_snprintf(szCGIArgs, sizeof(szCGIArgs), " -f \"%s\"", szINFfile);
- /* remove this instance */
- status = run_cgi(pszServerRoot, "bin\\slapd\\admin\\bin\\ds_remove.exe", szCGIArgs);
-
- /* remove temp inffile */
- _unlink(szINFfile);
- return (status == 0); /* return true if run_cgi succeeded */
- }
- BOOL RemoveMiscRegistryEntries(void)
- {
- BOOL bRC = TRUE;
- RemoveSNMPKeys();
- RemoveSNMPValue();
-
- return bRC;
- }
- BOOL RemoveMiscSlapdFiles(pszServerRoot)
- {
- char *miscFilesList[] =
- {
- "dsgw",
- "plugins\\slapd",
- "plugins\\snmp\\netscape-ldap.mib",
- "bin\\slapd",
- "manual\\slapd",
- "relnotes.gif",
- "relnotes.html",
- "slapd.txt",
- "unsynch.exe",
- "mcc.bat",
- "authdb",
- "setup\\slapd",
- "ldap.info",
- NULL
- };
- int i;
-
- CHAR szFileName[MAX_STR_SIZE];
- for(i=0; miscFilesList[i] != NULL; i++)
- {
- memset(szFileName, '\0', MAX_STR_SIZE);
- my_snprintf(szFileName, sizeof(szFileName), "%s\\%s", pszServerRoot, miscFilesList[i] );
- DeleteRecursively(szFileName);
- }
- return TRUE;
- }
- //////////////////////////////////////////////////////////////////////////////
- // PreUninst
- //
- //
- // Do things before uninstalling like turn off the server
- //
- //
- //
- //
- BOOL __declspec(dllexport)
- DSINST_PreUnInstall(LPCSTR pszServerRoot)
- {
- BOOL rc = TRUE;
- BOOL snmpstatus;
- WIN32_FIND_DATA fileData;
- HANDLE hFileHandle;
- CHAR szCurrentDir[MAX_STR_SIZE]="\0";
- /* for now just turn of the one instance we install */
- /* later look in directory for anything slapd- and turn that off */
-
- /* stevross: do this here until decide what to do with
- DeleteServerRegistryKeys in Remove Instance */
- /* get current dir so we have it for later */
- GetCurrentDirectory(MAX_STR_SIZE, szCurrentDir);
-
- /* change current dir to server root */
- SetCurrentDirectory(pszServerRoot);
- /* Turn off SNMP Service if Running */
- snmpstatus = getSNMPStatus();
- /* remove SNMP keys and any other Misc stuff */
- RemoveMiscRegistryEntries();
- hFileHandle = FindFirstFile("slapd-*", &fileData);
- if( INVALID_HANDLE_VALUE != hFileHandle)
- {
- rc = RemoveSlapdInstance(pszServerRoot, fileData.cFileName);
- while(TRUE == FindNextFile(hFileHandle, &fileData) )
- {
- BOOL status = RemoveSlapdInstance(pszServerRoot, fileData.cFileName);
- /* we want to report failure even if only 1 instance removal fails */
- if (rc)
- {
- rc = status;
- }
- }
- FindClose(hFileHandle);
- }
-
- /* turn SNMP service back on if it was running */
- if (snmpstatus)
- {
- if( 1 == mi.m_nSNMPOn)
- {
- if( 0 == ControlServer(SNMP_SERVICE, TRUE) )
- {
- /* complain but continue with install */
- DSMessageBoxOK(ERR_SNMP_BAD_STARTUP_TITLE,
- ERR_SNMP_BAD_STARTUP, 0);
- }
- }
- }
- /* set back to previous current directory */
- SetCurrentDirectory(szCurrentDir);
- /* unfortunately, if we just return FALSE here, uninstall will continue
- happily along, and ultimately remove the uninst.exe program which we
- need to run again after we figure out what went wrong
- So, we must exit here
- */
- if (!rc) {
- DSMessageBoxOK(ERR_UNINSTALL_DS_TITLE,
- ERR_UNINSTALL_DS, 0, LOGFILE);
- ExitProcess(1);
- }
- return rc;
- }
- //////////////////////////////////////////////////////////////////////////////
- // PostUninst
- //
- //
- // Clean up registry keys etc
- //
- //
- //
- //
- BOOL __declspec(dllexport)
- DSINST_PostUnInstall(LPCSTR pszServerRoot)
- {
- BOOL bRC = TRUE;
- /* remove misc files */
-
- RemovePerfMon();
- RemoveMiscSlapdFiles(pszServerRoot);
- RemoveDirectoryRootKey();
-
- return bRC;
- }
- //////////////////////////////////////////////////////////////////////////////
- // DllMain
- //
- // The Windows DLL main entry point. Called upon loading the DLL into memory.
- // Perform all initialization in the DLL_PROCESS_ATTACH reason handler, and
- // release any resources that you have allocated in the DLL_PROCESS_DETACH
- // message handler. See the Windows SDK documentation for more information
- // on this function.
- //
- BOOL WINAPI
- DllMain(HANDLE hModule, ULONG ulReasonForCall, LPVOID lpReserved)
- {
- switch (ulReasonForCall)
- {
- case DLL_PROCESS_ATTACH:
- mi.m_hModule = hModule;
- StartWSA();
- initialize_module();
- /* set default server settings */
- set_default_ldap_settings();
- break;
- case DLL_PROCESS_DETACH:
- break;
- case DLL_THREAD_ATTACH:
- break;
- case DLL_THREAD_DETACH:
- break;
- }
- return TRUE;
- }
- static void
- fixDN(char *dn)
- {
- if (dn && *dn)
- {
- char *utf8dn = localToUTF8(dn);
- char *localdn = NULL;
- dn_normalize_convert(utf8dn);
- localdn = UTF8ToLocal(utf8dn);
- strcpy(dn, localdn);
- nsSetupFree(utf8dn);
- nsSetupFree(localdn);
- }
- }
- static void
- fixURL(char *url)
- {
- if (url && *url)
- {
- char host[MAX_STR_SIZE];
- int port;
- char base[MAX_STR_SIZE];
- GetURLComponents(url, host, &port, base);
- fixDN(base);
- my_snprintf(url, MAX_STR_SIZE, "ldap://%s:%d/%s", host, port, base);
- }
- }
-
- static void
- normalizeDNs()
- {
- fixDN(mi.m_szMCCSuffix);
- fixDN(mi.m_szUGSuffix);
- fixDN(mi.m_szInstallDN);
- fixDN(mi.m_szInstanceSuffix);
- fixDN(mi.m_szInstanceUnrestrictedUser);
- fixDN(mi.m_szSupplierDN);
- fixDN(mi.m_szChangeLogSuffix);
- fixDN(mi.m_szConsumerDN);
- fixDN(mi.m_szConsumerBindAs);
- fixDN(mi.m_szSupplierBindAs);
- fixDN(mi.m_szConsumerRoot);
- fixDN(mi.m_szSupplierRoot);
- fixURL(mi.m_szLdapURL);
- fixURL(mi.m_szUserGroupURL);
- }
- /*
- Usage:
- DSMessageBox(type, titleKey, msgKey, titlearg, msgarg1, ..., msgargN);
- */
- int
- DSMessageBox(UINT type, UINT titleKey, UINT msgKey, const char *titlearg, ...)
- {
- int retval = 0;
- va_list ap;
- CHAR msgFormat[MAX_STR_SIZE] = {0};
- CHAR msg[MAX_STR_SIZE*2] = {0};
- CHAR titleFormat[MAX_STR_SIZE] = {0};
- CHAR title[MAX_STR_SIZE] = {0};
- LoadString(mi.m_hModule, msgKey, msgFormat, MAX_STR_SIZE);
- if (!msgFormat[0])
- return retval;
- if (titleKey >= 0)
- LoadString(mi.m_hModule, titleKey, titleFormat, MAX_STR_SIZE);
- va_start(ap, titlearg);
- _vsnprintf(msg, sizeof(msg), msgFormat, ap);
- va_end(ap);
- msg[sizeof(msg)-1] = (char)0;
- LogData(NULL, msg);
- myLogData(msg);
- if (SILENTMODE != MODE)
- {
- if (titleFormat[0])
- {
- my_snprintf(title, sizeof(title), titleFormat, titlearg);
- retval = NsSetupMessageBox(NULL, msg, title, type);
- }
- else
- retval = NsSetupMessageBox(NULL, msg, NULL, type);
- }
- else
- {
- retval = IDOK; /* force OK for silent mode */
- }
- return retval;
- }
- /*
- Usage:
- DSMessageBoxOK(titleKey, msgKey, titlearg, msgarg1, ..., msgargN);
- */
- int
- DSMessageBoxOK(UINT titleKey, UINT msgKey, const char *titlearg, ...)
- {
- int retval = 0;
- va_list ap;
- CHAR msgFormat[MAX_STR_SIZE] = {0};
- CHAR msg[MAX_STR_SIZE*2] = {0};
- CHAR titleFormat[MAX_STR_SIZE] = {0};
- CHAR title[MAX_STR_SIZE] = {0};
- LoadString(mi.m_hModule, msgKey, msgFormat, MAX_STR_SIZE);
- if (!msgFormat[0])
- return retval;
- if (titleKey >= 0)
- LoadString(mi.m_hModule, titleKey, titleFormat, MAX_STR_SIZE);
- va_start(ap, titlearg);
- _vsnprintf(msg, sizeof(msg), msgFormat, ap);
- va_end(ap);
- msg[sizeof(msg)-1] = (char)0;
- LogData(NULL, msg);
- if (MODE != SILENTMODE)
- {
- if (titleFormat[0])
- {
- my_snprintf(title, sizeof(title), titleFormat, titlearg);
- retval = NsSetupMessageBox(NULL, msg, title, MB_OK);
- }
- else
- retval = NsSetupMessageBox(NULL, msg, NULL, MB_OK);
- }
- else
- {
- myLogData(msg); /* log the message */
- retval = IDOK; /* force true return if silent mode */
- }
- return retval;
- }
|