dsinst.c 261 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372
  1. /** BEGIN COPYRIGHT BLOCK
  2. * This Program is free software; you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation; version 2 of the License.
  5. *
  6. * This Program is distributed in the hope that it will be useful, but WITHOUT
  7. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  8. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  9. *
  10. * You should have received a copy of the GNU General Public License along with
  11. * this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
  12. * Place, Suite 330, Boston, MA 02111-1307 USA.
  13. *
  14. * In addition, as a special exception, Red Hat, Inc. gives You the additional
  15. * right to link the code of this Program with code not covered under the GNU
  16. * General Public License ("Non-GPL Code") and to distribute linked combinations
  17. * including the two, subject to the limitations in this paragraph. Non-GPL Code
  18. * permitted under this exception must only link to the code of this Program
  19. * through those well defined interfaces identified in the file named EXCEPTION
  20. * found in the source code files (the "Approved Interfaces"). The files of
  21. * Non-GPL Code may instantiate templates or use macros or inline functions from
  22. * the Approved Interfaces without causing the resulting work to be covered by
  23. * the GNU General Public License. Only Red Hat, Inc. may make changes or
  24. * additions to the list of Approved Interfaces. You must obey the GNU General
  25. * Public License in all respects for all of the Program code and other code used
  26. * in conjunction with the Program except the Non-GPL Code covered by this
  27. * exception. If you modify this file, you may extend this exception to your
  28. * version of the file, but you are not obligated to do so. If you do not wish to
  29. * provide this exception without modification, you must delete this exception
  30. * statement from your version and license this file solely under the GPL without
  31. * exception.
  32. *
  33. *
  34. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  35. * Copyright (C) 2005 Red Hat, Inc.
  36. * All rights reserved.
  37. * END COPYRIGHT BLOCK **/
  38. ///////////////////////////////////////////////////////////////////////////////
  39. // dsinst.c - Fedora Directory Server Installation Plug-In
  40. //
  41. #include <windows.h>
  42. #include <commctrl.h>
  43. #include <nssetup.h>
  44. #include <ldapu.h>
  45. #include <time.h>
  46. #include <sys/types.h>
  47. #include <sys/stat.h>
  48. #include <stdio.h>
  49. #include <process.h>
  50. #include <regstr.h>
  51. #include <ldap.h>
  52. #include <wingdi.h>
  53. #include "resource.h"
  54. #include "dsinst.h"
  55. #include "install_keywords.h"
  56. #include "libinst.h"
  57. #ifdef TARGETDIR
  58. #undef TARGETDIR
  59. #endif
  60. #define NUM_PROP_PAGES 16
  61. // this is the path to perl, relative to the server root directory
  62. #define PERL_EXE "bin\\slapd\\admin\\bin\\perl.exe"
  63. // this is the keyword to lookup in slapd.inf
  64. #define NSPERL_POST_INSTALL_PROG "NSPerlPostInstall"
  65. #define INDEX_FIRST_PAGE 0
  66. #define INDEX_LAST_PAGE 14
  67. #define NUM_CIR_ATTR 12
  68. #define NUM_ORC_ATTR 1
  69. #define NUM_SIR_ATTR 10
  70. static MODULEINFO mi = {
  71. NULL, // m_hModule
  72. NULL, // m_hwndParent
  73. NS_WIZERROR, // m_nResult
  74. 0, // m_nReInstall
  75. NULL, // m_szMCCBindAs
  76. };
  77. static INFDATA cd;
  78. static void normalizeDNs();
  79. extern int ds_dn_uses_LDAPv2_quoting(const char *utf8dn);
  80. extern char *dn_normalize_convert(char *dn);
  81. static void fixDN(char *dn);
  82. static char *dialogMessage; /* used by shutdownDialogProc */
  83. #define OLD_VERSION_SIZE 32
  84. static char oldVersion[OLD_VERSION_SIZE]; /* used by reinstall */
  85. static int
  86. my_snprintf(char *s, size_t size, const char *fmt, ...)
  87. {
  88. int rc;
  89. va_list ap;
  90. va_start(ap, fmt);
  91. rc = _vsnprintf(s, size, fmt, ap);
  92. va_end(ap);
  93. s[size-1] = (char)0;
  94. return rc;
  95. }
  96. static void
  97. my_strncpy(char *dst, const char *src, size_t size)
  98. {
  99. strncpy(dst, src, size-1);
  100. dst[size-1] = (char)0;
  101. }
  102. static void
  103. storeUserDirectoryInfo()
  104. {
  105. char *utf8UserGroupAdmin = NULL;
  106. char *utf8UserGroupAdminPW = NULL;
  107. char *utf8UserGroupURL = NULL;
  108. if (mi.m_nReInstall == 1)
  109. return; // do nothing if reinstall
  110. if(mi.m_nExistingUG == 0)
  111. {
  112. /* the user is creating a new UG with this instance */
  113. if(mi.m_nExistingMCC == 0)
  114. {
  115. /* the user is also creating a new MCC so set UG admin to MCC admin */
  116. my_strncpy(mi.m_szUserGroupAdmin, mi.m_szMCCBindAs, sizeof(mi.m_szUserGroupAdmin));
  117. my_strncpy(mi.m_szUserGroupAdminPW, mi.m_szMCCPw, sizeof(mi.m_szUserGroupAdminPW));
  118. }else{
  119. /* user is using an existing MCC so only creating UG, make UG user same as
  120. Root DN */
  121. my_strncpy(mi.m_szUserGroupAdmin, mi.m_szInstanceUnrestrictedUser, sizeof(mi.m_szUserGroupAdmin));
  122. my_strncpy(mi.m_szUserGroupAdminPW, mi.m_szInstancePassword, sizeof(mi.m_szUserGroupAdminPW));
  123. }
  124. my_snprintf(mi.m_szUserGroupURL, sizeof(mi.m_szUserGroupURL), "ldap://%s:%d/%s", mi.m_szInstanceHostName,
  125. mi.m_nInstanceServerPort, mi.m_szInstanceSuffix);
  126. }
  127. SetLdapUserDirInit(TRUE);
  128. utf8UserGroupAdmin = localToUTF8(mi.m_szUserGroupAdmin);
  129. utf8UserGroupAdminPW = localToUTF8(mi.m_szUserGroupAdminPW);
  130. utf8UserGroupURL = localToUTF8(mi.m_szUserGroupURL);
  131. SetLdapUserDirID(utf8UserGroupAdmin);
  132. SetLdapUserDirPWD(utf8UserGroupAdminPW);
  133. SetLdapUserDirURL(utf8UserGroupURL);
  134. nsSetupFree(utf8UserGroupAdmin);
  135. nsSetupFree(utf8UserGroupAdminPW);
  136. nsSetupFree(utf8UserGroupURL);
  137. }
  138. /* converts server ID of the form slapd-foo to foo, and NULL to "" */
  139. static const char *
  140. getShortName(const char *serverID)
  141. {
  142. const char *retval = serverID;
  143. const char *prefix = "slapd-";
  144. int preflen = strlen(prefix);
  145. if (serverID && !strncmp(serverID, prefix, preflen))
  146. retval = serverID + preflen;
  147. if (!retval)
  148. retval = "";
  149. return retval;
  150. }
  151. static FILE*
  152. getLogFileP()
  153. {
  154. static FILE* logfp = 0;
  155. if (!getenv("USE_LOGFILE"))
  156. return logfp;
  157. if (!logfp)
  158. logfp = fopen("c:\\debug.out", "w");
  159. return logfp;
  160. }
  161. static void
  162. myLogData(const char *s, ...)
  163. {
  164. FILE* logfp = getLogFileP();
  165. va_list ap;
  166. if (!logfp)
  167. return;
  168. va_start(ap, s);
  169. vfprintf(logfp, s, ap);
  170. va_end(ap);
  171. fprintf(logfp, "\n");
  172. fflush(logfp);
  173. }
  174. /* Will return a malloc'd "" if no error - so caller should always use LocalFree() with
  175. the returned value
  176. */
  177. static LPVOID
  178. getLastErrorMessage()
  179. {
  180. LPVOID lpMsgBuf = NULL;
  181. FormatMessage(
  182. FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
  183. NULL,
  184. GetLastError(),
  185. MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
  186. (LPTSTR) &lpMsgBuf,
  187. 0,
  188. NULL);
  189. /* always return something . . . */
  190. if (lpMsgBuf == NULL) {
  191. lpMsgBuf = strdup("");
  192. }
  193. return lpMsgBuf;
  194. }
  195. static void
  196. myLogError(const char *s, ...)
  197. {
  198. va_list ap;
  199. LPVOID lpMsgBuf;
  200. FILE* logfp = getLogFileP();
  201. if (!logfp)
  202. return;
  203. if (lpMsgBuf = getLastErrorMessage()) {
  204. fprintf(logfp, "Error: %d (%s): at ", GetLastError(), lpMsgBuf);
  205. // Free the buffer.
  206. LocalFree( lpMsgBuf );
  207. }
  208. va_start(ap, s);
  209. vfprintf(logfp, s, ap);
  210. va_end(ap);
  211. }
  212. /*
  213. prints a message if the given dn uses LDAPv2 style quoting
  214. */
  215. void
  216. checkForLDAPv2Quoting(const char *dn_to_test)
  217. {
  218. char *utf8dn = localToUTF8(dn_to_test);
  219. if (ds_dn_uses_LDAPv2_quoting(utf8dn))
  220. {
  221. char *newdn = strdup(dn_to_test);
  222. fixDN(newdn);
  223. DSMessageBoxOK(WARN_USING_LDAPV2_QUOTES_TITLE,
  224. WARN_USING_LDAPV2_QUOTES,
  225. dn_to_test, dn_to_test, newdn);
  226. free(newdn);
  227. }
  228. if (utf8dn)
  229. nsSetupFree(utf8dn);
  230. return;
  231. }
  232. int
  233. IsValidAdminDomain(
  234. const char *host,
  235. int port,
  236. const char *suffix,
  237. const char *admin_domain,
  238. const char *binddn,
  239. const char *binddnpwd
  240. )
  241. {
  242. char ldapurl[4096];
  243. int status = FALSE;
  244. Ldap *ldap = NULL;
  245. my_snprintf(ldapurl, sizeof(ldapurl), "ldap://%s:%d/%s", host, port, suffix);
  246. if (createLdap(&ldap, ldapurl, binddn, binddnpwd, 0, 0) == OKAY)
  247. {
  248. LdapEntry *le = createLdapEntry(ldap);
  249. char *dn = formAdminDomainDN(admin_domain);
  250. if (le && dn && entryExists(le, dn))
  251. status = TRUE;
  252. if (dn)
  253. nsSetupFree(dn);
  254. if (le)
  255. destroyLdapEntry(le);
  256. }
  257. if (ldap)
  258. destroyLdap(ldap);
  259. return status;
  260. }
  261. void ControlSlapdInstance(char *pszServiceName, BOOL bOn);
  262. static void ConvertPasswordToPin(char *pszServerRoot, char *pszServiceName);
  263. static void ReinstallUpgradeServer(char *pszServerRoot, char *pszServiceName);
  264. char *getGMT()
  265. {
  266. static char buf[20];
  267. time_t curtime;
  268. struct tm ltm;
  269. curtime = time( (time_t *)0 );
  270. #ifdef _WIN32
  271. ltm = *gmtime( &curtime );
  272. #else
  273. gmtime_r( &curtime, &ltm );
  274. #endif
  275. strftime( buf, sizeof(buf), "%Y%m%d%H%M%SZ", &ltm );
  276. return buf;
  277. }
  278. char *onezero2yesno(int value)
  279. {
  280. if (1 == value)
  281. {
  282. return "yes";
  283. }else{
  284. return "no";
  285. }
  286. }
  287. int yesno2onezero(char *value)
  288. {
  289. if(!lstrcmpi("yes", value) )
  290. {
  291. return 1;
  292. }else{
  293. return 0;
  294. }
  295. }
  296. ////////////////
  297. ///
  298. // determine whether a string contains 8 bit characters
  299. //
  300. static int
  301. contains8BitChars(const char *s)
  302. {
  303. int ret = 0;
  304. if (s && *s)
  305. {
  306. for (; !ret && *s; ++s)
  307. {
  308. ret = (*s & 0x80);
  309. }
  310. }
  311. return ret;
  312. }
  313. ////////////////
  314. ///
  315. // determine whether a dn is valid or not
  316. //
  317. static int
  318. isAValidDN(const char *dn_to_test)
  319. {
  320. int ret = 1;
  321. if (!dn_to_test || !*dn_to_test)
  322. {
  323. ret = 0;
  324. }
  325. else
  326. {
  327. char *utf8dn = localToUTF8(dn_to_test);
  328. char **rdnList = ldap_explode_dn(utf8dn, 0);
  329. char **rdnNoTypes = ldap_explode_dn(utf8dn, 1);
  330. if (!rdnList || !rdnList[0] || !rdnNoTypes || !rdnNoTypes[0] ||
  331. !*rdnNoTypes[0] || !stricmp(rdnList[0], rdnNoTypes[0]))
  332. {
  333. ret = 0;
  334. }
  335. if (rdnList)
  336. ldap_value_free(rdnList);
  337. if (rdnNoTypes)
  338. ldap_value_free(rdnNoTypes);
  339. if (utf8dn)
  340. nsSetupFree(utf8dn);
  341. }
  342. if ((ret == 1) && dn_to_test)
  343. checkForLDAPv2Quoting(dn_to_test);
  344. return ret;
  345. }
  346. ////////////////
  347. ///
  348. // check if DN is valid, display error if not
  349. // returns 1 if dn is valid
  350. // 0 if dn is invalid
  351. int isValidDN(char *dn)
  352. {
  353. int nReturn;
  354. if( 0 == (nReturn = isAValidDN(dn)) )
  355. DSMessageBoxOK(ERR_INVALID_DN_TITLE, ERR_INVALID_DN, dn, dn);
  356. return nReturn;
  357. }
  358. ////////////////
  359. ///
  360. // check if port is valid, display error if not
  361. // returns 1 if port is valid
  362. // 0 if port is invalid
  363. int isValidPort(int port)
  364. {
  365. int nReturn = 1;
  366. if (port <= 0 || port > MAXPORT)
  367. {
  368. DSMessageBoxOK(ERR_INVALID_PORT_TITLE, ERR_INVALID_PORT, 0,
  369. port);
  370. nReturn = 0;
  371. }
  372. return nReturn;
  373. }
  374. ////////////////
  375. ///
  376. // get the components out of an ldapurl
  377. //
  378. //
  379. int GetURLComponents(char *szURL, char *szHost, int *nPort, char *szBase)
  380. {
  381. LDAPURLDesc *ludpp;
  382. int res;
  383. if ( ( res = ldap_url_parse( szURL, &ludpp ) ) != 0 )
  384. {
  385. return res;
  386. }
  387. if( NULL != ludpp->lud_host)
  388. {
  389. my_strncpy(szHost, ludpp->lud_host, MAX_STR_SIZE);
  390. }else{
  391. strcpy(szHost, "\0");
  392. }
  393. *nPort = ludpp->lud_port;
  394. if( NULL != ludpp->lud_dn)
  395. {
  396. my_strncpy(szBase, ludpp->lud_dn, MAX_STR_SIZE);
  397. }else{
  398. strcpy(szBase, "\0");
  399. }
  400. ldap_free_urldesc( ludpp );
  401. return 0;
  402. }
  403. ////////////////
  404. ///
  405. //
  406. //
  407. void StartWSA()
  408. {
  409. WORD wVersionRequested;
  410. WSADATA wsaData;
  411. int err;
  412. wVersionRequested = MAKEWORD( 2, 0 );
  413. err = WSAStartup( wVersionRequested, &wsaData );
  414. if ( err != 0 ) {
  415. /* Tell the user that we couldn't find a usable */
  416. /* WinSock DLL. */
  417. DSMessageBoxOK(ERR_NO_WINSOCK_TITLE, ERR_NO_WINSOCK, 0);
  418. return;
  419. }
  420. /* Confirm that the WinSock DLL supports 2.0.*/
  421. /* Note that if the DLL supports versions greater */
  422. /* than 2.0 in addition to 2.0, it will still return */
  423. /* 2.0 in wVersion since that is the version we */
  424. /* requested. */
  425. if ( LOBYTE( wsaData.wVersion ) != 2 ||
  426. HIBYTE( wsaData.wVersion ) != 0 ) {
  427. /* Tell the user that we couldn't find a usable */
  428. /* WinSock DLL. */
  429. DSMessageBoxOK(ERR_NO_WINSOCK_VER_TITLE, ERR_NO_WINSOCK_VER, 0);
  430. WSACleanup( );
  431. return;
  432. }
  433. /* The WinSock DLL is acceptable. Proceed. */
  434. }
  435. ////////////////
  436. //
  437. //
  438. //
  439. BOOL FullyQualifyHostName(char * HostName)
  440. {
  441. static char * domain = 0;
  442. struct hostent * hptr;
  443. BOOL bRC = TRUE;
  444. hptr = (struct hostent*)gethostbyname(HostName);
  445. if (hptr) {
  446. /* See if h_name is fully-qualified */
  447. if (hptr->h_name) {
  448. domain = strchr(hptr->h_name, '.');
  449. sprintf(HostName,"%s",hptr->h_name);
  450. return bRC;
  451. }
  452. /* Otherwise look for a fully qualified alias */
  453. if ((domain == 0) &&
  454. (hptr->h_aliases && hptr->h_aliases[0])) {
  455. char **p;
  456. for (p = hptr->h_aliases; *p; ++p) {
  457. domain = strchr(*p, '.');
  458. if (domain) break;
  459. }
  460. }
  461. }
  462. if (domain != 0)
  463. {
  464. if (domain[0] == '.')
  465. {
  466. ++domain;
  467. }
  468. sprintf(HostName,"%s.%s", HostName, domain);
  469. } else
  470. {
  471. bRC = FALSE;
  472. }
  473. return bRC;
  474. }
  475. /////////////////
  476. //
  477. // UTF8IsValidLdapUser
  478. //
  479. // converts necessary things to UTF8 before calling server
  480. //
  481. BOOL UTF8IsValidLdapUser(char *szHost, int nPort, char *szSuffix, char *szBindAs, char *szPw, BOOL bParam)
  482. {
  483. char *utf8Host=NULL;
  484. char *utf8Suffix=NULL;
  485. char *utf8BindAs=NULL;
  486. char *utf8Pw=NULL;
  487. BOOL bReturn;
  488. /* convert to UTF8 first incase international data */
  489. utf8Host = localToUTF8(szHost);
  490. utf8Suffix = localToUTF8(szSuffix);
  491. utf8BindAs = localToUTF8(szBindAs);
  492. utf8Pw = localToUTF8(szPw);
  493. bReturn = IsValidLdapUser(utf8Host, nPort, utf8Suffix, &utf8BindAs, utf8Pw, bParam);
  494. if( utf8Host) nsSetupFree(utf8Host);
  495. if( utf8Suffix) nsSetupFree(utf8Suffix);
  496. if( utf8BindAs) nsSetupFree(utf8BindAs);
  497. if( utf8Pw) nsSetupFree(utf8Pw);
  498. return bReturn;
  499. }
  500. /////////////////
  501. //
  502. // UTF8IsValidAdminDomain
  503. //
  504. // converts necessary things to UTF8 before calling server
  505. //
  506. BOOL UTF8IsValidAdminDomain(char *szHost, int nPort, char *szSuffix, char *szAdminDomain, char *szBindAs, char *szPw)
  507. {
  508. char *utf8Host=NULL;
  509. char *utf8Suffix=NULL;
  510. char *utf8BindAs=NULL;
  511. char *utf8Pw=NULL;
  512. char *utf8AdminDomain=NULL;
  513. BOOL bReturn;
  514. /* convert to UTF8 first incase international data */
  515. utf8Host = localToUTF8(szHost);
  516. utf8Suffix = localToUTF8(szSuffix);
  517. utf8BindAs = localToUTF8(szBindAs);
  518. utf8Pw = localToUTF8(szPw);
  519. utf8AdminDomain = localToUTF8(szAdminDomain);
  520. bReturn = IsValidAdminDomain(utf8Host, nPort, utf8Suffix, utf8AdminDomain, utf8BindAs, utf8Pw);
  521. if( utf8Host) nsSetupFree(utf8Host);
  522. if( utf8Suffix) nsSetupFree(utf8Suffix);
  523. if( utf8BindAs) nsSetupFree(utf8BindAs);
  524. if( utf8Pw) nsSetupFree(utf8Pw);
  525. if( utf8AdminDomain) nsSetupFree(utf8AdminDomain);
  526. return bReturn;
  527. }
  528. void getAdminServInfo()
  529. {
  530. char *pszAdminSection="admin";
  531. char szTempDir[MAX_PATH];
  532. char szCacheFile[MAX_PATH];
  533. GetEnvironmentVariable("TEMP", szTempDir, sizeof(szTempDir));
  534. my_snprintf(szCacheFile, sizeof(szCacheFile), "%s\\install.inf", szTempDir);
  535. mi.m_nAdminServerPort = GetPrivateProfileInt(pszAdminSection, SLAPD_KEY_ADMIN_SERVER_PORT,
  536. -1, szCacheFile);
  537. if (mi.m_nAdminServerPort == -1) {
  538. myLogData("Warning: Could not determine admin server port for Directory Server Gateway and Orgchart configuration files. Please update them manually.");
  539. mi.m_nAdminServerPort = DEFAULT_ADMIN_PORT;
  540. }
  541. }
  542. BOOL writeINFfile(const char *filename)
  543. {
  544. FILE *fp = fopen(filename, "wb");
  545. if (NULL == fp)
  546. return FALSE;
  547. if(0 == lstrcmp("\0", mi.m_szInstallDN) )
  548. {
  549. char * szAdminDN = NULL;
  550. szAdminDN = formAdminDomainDN(mi.m_szAdminDomain);
  551. if (szAdminDN)
  552. {
  553. my_snprintf(mi.m_szInstallDN, sizeof(mi.m_szInstallDN), szAdminDN);
  554. nsSetupFree(szAdminDN);
  555. }
  556. else
  557. {
  558. //note probably should fail.
  559. LogData(NULL, "Warning: Slapd unable to Form Admin Domain, guessing");
  560. my_snprintf(mi.m_szInstallDN, sizeof(mi.m_szInstallDN), "ou=%s, o=NetscapeRoot", mi.m_szAdminDomain);
  561. }
  562. }
  563. // write global section header
  564. fprintf(fp, "[General]\n");
  565. fprintf(fp, "%s= %s\n", GLOBAL_INF_LDAP_USED, "TRUE");
  566. fprintf(fp, "%s= %s\n", SLAPD_KEY_SERVER_ADMIN_ID, mi.m_szMCCBindAs);
  567. fprintf(fp, "%s= %s\n", SLAPD_KEY_SERVER_ADMIN_PWD, mi.m_szMCCPw);
  568. fprintf(fp, "%s= %s\n", SLAPD_KEY_FULL_MACHINE_NAME, mi.m_szInstanceHostName);
  569. fprintf(fp, "%s= %s\n", SLAPD_KEY_SERVER_ROOT, TARGETDIR);
  570. fprintf(fp, "%s= %s\n", SLAPD_KEY_K_LDAP_URL, mi.m_szLdapURL);
  571. fprintf(fp, "%s= %s\n", SLAPD_KEY_ADMIN_DOMAIN, mi.m_szAdminDomain);
  572. fprintf(fp, "%s= %s\n", SLAPD_KEY_USER_GROUP_LDAP_URL, mi.m_szUserGroupURL);
  573. fprintf(fp, "%s= %s\n", SLAPD_KEY_USER_GROUP_ADMIN_ID, mi.m_szUserGroupAdmin);
  574. fprintf(fp, "%s= %s\n", SLAPD_KEY_USER_GROUP_ADMIN_PWD, mi.m_szUserGroupAdminPW);
  575. // write Admin section header.
  576. getAdminServInfo(); /* Right now this only gets the admin port. If you want more,
  577. you'll have to change getAdminServInfo.*/
  578. fprintf(fp, "\n[admin]\n");
  579. fprintf(fp, "%s= %d\n", SLAPD_KEY_ADMIN_SERVER_PORT, mi.m_nAdminServerPort);
  580. // write DS section header
  581. fprintf(fp, "\n[slapd]\n");
  582. fprintf(fp, "%s= %d\n", SLAPD_KEY_SERVER_PORT, mi.m_nInstanceServerPort);
  583. if(0 == mi.m_nExistingUG)
  584. {
  585. /* don't write this key when config only directory */
  586. /* config only directory when using existing data store */
  587. fprintf(fp, "%s= %s\n", SLAPD_KEY_SUFFIX, mi.m_szInstanceSuffix);
  588. }
  589. fprintf(fp, "%s= %s\n", SLAPD_KEY_USE_EXISTING_MC,
  590. onezero2yesno(mi.m_nExistingMCC));
  591. fprintf(fp, "%s= %s\n", SLAPD_KEY_USE_EXISTING_UG,
  592. onezero2yesno(mi.m_nExistingUG));
  593. fprintf(fp, "%s= %s\n", SLAPD_KEY_ROOTDN, mi.m_szInstanceUnrestrictedUser);
  594. fprintf(fp, "%s= %s\n", SLAPD_KEY_ROOTDNPWD, mi.m_szInstancePassword);
  595. fprintf(fp, "%s= %s\n", SLAPD_KEY_SERVER_IDENTIFIER, mi.m_szServerIdentifier);
  596. fprintf(fp, "%s= %s\n", SLAPD_KEY_SLAPD_CONFIG_FOR_MC, onezero2yesno(mi.m_nCfgSspt) );
  597. fprintf(fp, "%s= %s\n", SLAPD_KEY_ADD_SAMPLE_ENTRIES, onezero2yesno(mi.m_nPopulateSampleEntries));
  598. fprintf(fp, "%s= %s\n", SLAPD_KEY_ADD_ORG_ENTRIES, onezero2yesno(mi.m_nPopulateSampleOrg));
  599. fprintf(fp, "%s= %s\n", SLAPD_KEY_USE_REPLICATION, onezero2yesno(
  600. (mi.m_nSetupConsumerReplication || mi.m_nSetupSupplierReplication) ));
  601. /* consumer replication settings */
  602. fprintf(fp, "%s= %d\n", SLAPD_KEY_SETUP_CONSUMER, mi.m_nSetupConsumerReplication);
  603. fprintf(fp, "%s= %s\n", SLAPD_KEY_CIR_HOST, mi.m_szConsumerHost);
  604. fprintf(fp, "%s= %d\n", SLAPD_KEY_CIR_PORT, mi.m_nConsumerPort);
  605. fprintf(fp, "%s= %s\n", SLAPD_KEY_CIR_SUFFIX, mi.m_szConsumerRoot);
  606. fprintf(fp, "%s= %s\n", SLAPD_KEY_CIR_BINDDN, mi.m_szConsumerBindAs);
  607. fprintf(fp, "%s= %s\n", SLAPD_KEY_CIR_BINDDNPWD, mi.m_szConsumerPw);
  608. fprintf(fp, "%s= %s\n", SLAPD_KEY_CIR_SECURITY_ON, onezero2yesno(mi.m_nConsumerSSL));
  609. fprintf(fp, "%s= %d\n", SLAPD_KEY_CIR_INTERVAL, mi.m_nCIRInterval);
  610. if(!strcmp(DEFAULT_CIR_DAYS, mi.m_szCIRDays) )
  611. {
  612. /* if default of all days write null to inf file as that is what cgi wants */
  613. fprintf(fp, "%s=\n", SLAPD_KEY_CIR_DAYS);
  614. }else{
  615. fprintf(fp, "%s= %s\n", SLAPD_KEY_CIR_DAYS, mi.m_szCIRDays);
  616. }
  617. if(!strcmp(DEFAULT_CIR_TIMES, mi.m_szCIRTimes) )
  618. {
  619. /* if default of all times write null to inf file as that is what cgi wants */
  620. fprintf(fp, "%s=\n", SLAPD_KEY_CIR_TIMES);
  621. }else{
  622. fprintf(fp, "%s= %s\n", SLAPD_KEY_CIR_TIMES, mi.m_szCIRTimes);
  623. }
  624. fprintf(fp, "%s= %s\n", SLAPD_KEY_REPLICATIONDN, mi.m_szSupplierDN);
  625. fprintf(fp, "%s= %s\n", SLAPD_KEY_REPLICATIONPWD, mi.m_szSupplierPW);
  626. /* Supplier replication settings */
  627. fprintf(fp, "%s= %d\n", SLAPD_KEY_SETUP_SUPPLIER, mi.m_nSetupSupplierReplication);
  628. fprintf(fp, "%s= %s\n", SLAPD_KEY_CHANGELOGDIR, mi.m_szChangeLogDbDir);
  629. fprintf(fp, "%s= %s\n", SLAPD_KEY_CHANGELOGSUFFIX, mi.m_szChangeLogSuffix);
  630. fprintf(fp, "%s= %s\n", SLAPD_KEY_SIR_HOST, mi.m_szSupplierHost);
  631. fprintf(fp, "%s= %d\n", SLAPD_KEY_SIR_PORT, mi.m_nSupplierPort);
  632. fprintf(fp, "%s= %s\n", SLAPD_KEY_SIR_SUFFIX, mi.m_szSupplierRoot);
  633. fprintf(fp, "%s= %s\n", SLAPD_KEY_SIR_BINDDN, mi.m_szSupplierBindAs);
  634. fprintf(fp, "%s= %s\n", SLAPD_KEY_SIR_BINDDNPWD, mi.m_szSupplierPw);
  635. fprintf(fp, "%s= %s\n", SLAPD_KEY_SIR_SECURITY_ON, onezero2yesno(mi.m_nSupplierSSL));
  636. if(!strcmp(DEFAULT_SIR_DAYS, mi.m_szSIRDays) )
  637. {
  638. /* if default of all days write null to inf file as that is what cgi wants */
  639. fprintf(fp, "%s=\n", SLAPD_KEY_SIR_DAYS);
  640. }else{
  641. fprintf(fp, "%s= %s\n", SLAPD_KEY_SIR_DAYS, mi.m_szSIRDays);
  642. }
  643. if(!strcmp(DEFAULT_SIR_TIMES, mi.m_szSIRTimes) )
  644. {
  645. /* if default of all times write null to inf file as that is what cgi wants */
  646. fprintf(fp, "%s=\n", SLAPD_KEY_SIR_TIMES);
  647. }else{
  648. fprintf(fp, "%s= %s\n", SLAPD_KEY_SIR_TIMES, mi.m_szSIRTimes);
  649. }
  650. fprintf(fp, "%s= %s\n", LOCAL_INF_CONFIG_CONSUMER_DN, onezero2yesno(mi.m_nConfigConsumerDN));
  651. fprintf(fp, "%s= %s\n", SLAPD_KEY_CONSUMERDN, mi.m_szConsumerDN);
  652. fprintf(fp, "%s= %s\n", SLAPD_KEY_CONSUMERPWD, mi.m_szConsumerPW);
  653. fprintf(fp, "%s= %s\n", SLAPD_KEY_INSTALL_LDIF_FILE, mi.m_szPopLdifFile);
  654. fprintf(fp, "%s= %s\n", SLAPD_KEY_DISABLE_SCHEMA_CHECKING, onezero2yesno(mi.m_nDisableSchemaChecking));
  655. fprintf(fp, "%s= %d\n", LOCAL_INF_SNMP_ON, mi.m_nSNMPOn);
  656. fprintf(fp, "%s= %s\n", SLAPD_INSTALL_LOG_FILE_NAME, LOGFILE );
  657. fclose(fp);
  658. return TRUE;
  659. }
  660. //////////////////////////////////////////////////////////////////////////////
  661. // isValidServerID(char *pszServerIdentifier)
  662. //
  663. // check if valid serverid, for n
  664. //
  665. BOOL isValidServerID(char *pszServerIdentifier)
  666. {
  667. char *fullId;
  668. char line[MAX_PATH];
  669. DWORD Result;
  670. HKEY hServerKey;
  671. BOOL bRC = TRUE;
  672. /* first check that it only contains 7 bit characters */
  673. if( contains8BitChars(pszServerIdentifier) )
  674. {
  675. DSMessageBoxOK(ERR_8BIT_SERVID_TITLE, ERR_8BIT_SERVID, 0);
  676. bRC = FALSE;
  677. }else{
  678. /* looks ok, now check if it already exists */
  679. /* for now just check registry to see if this server ID exists,
  680. in future add might want to add more sanity checks */
  681. size_t len = strlen(DS_ID_SERVICE) + strlen(pszServerIdentifier) + 2;
  682. fullId = malloc(len);
  683. sprintf(fullId, "%s-%s", DS_ID_SERVICE, pszServerIdentifier);
  684. my_snprintf(line, sizeof(line), "%s\\%s", KEY_SERVICES, fullId);
  685. Result = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
  686. line,
  687. 0,
  688. KEY_ALL_ACCESS,
  689. &hServerKey);
  690. if (Result == ERROR_SUCCESS)
  691. {
  692. /* it already exists */
  693. DSMessageBoxOK(ERR_SERVER_ID_EXISTS_TITLE, ERR_SERVER_ID_EXISTS,
  694. getShortName(pszServerIdentifier),
  695. getShortName(pszServerIdentifier));
  696. bRC = FALSE;
  697. }
  698. free(fullId);
  699. }
  700. return bRC;
  701. }
  702. //////////////////////////////////////////////////////////////////////////////
  703. //
  704. // set_default_ldap_settings()
  705. //
  706. // hostname = getHostName
  707. // serverid = hostname up to first period
  708. // suffix = o=(rest of hostname) ie o=mcom.com
  709. // port = 389
  710. // rootDn = DirectoryManager
  711. int set_default_ldap_settings()
  712. {
  713. int i, j = 0;
  714. DSGetHostName(mi.m_szInstanceHostName, MAX_STR_SIZE);
  715. /* assumption: hostname up to first period for serverid */
  716. for( i = 0; !( (mi.m_szInstanceHostName[i] == '\0')
  717. || (mi.m_szInstanceHostName[i] == '.' ) );
  718. i++)
  719. {
  720. mi.m_szServerIdentifier[i] = mi.m_szInstanceHostName[i];
  721. }
  722. /* null terminate it */
  723. mi.m_szServerIdentifier[i]='\0';
  724. if (mi.m_szInstanceHostName[0] && strchr(mi.m_szInstanceHostName, '.'))
  725. {
  726. DSGetDefaultSuffix(mi.m_szInstanceSuffix, mi.m_szInstanceHostName);
  727. }
  728. else
  729. {
  730. strcpy(mi.m_szInstanceSuffix, "dc=example, dc=com");
  731. }
  732. /* default admin domain is also derived from the FQDN */
  733. ++i;
  734. my_snprintf(mi.m_szAdminDomain, sizeof(mi.m_szAdminDomain), "%s", mi.m_szInstanceHostName+i);
  735. mi.m_nInstanceServerPort=DEFAULT_SERVER_PORT;
  736. my_snprintf(mi.m_szInstanceUnrestrictedUser, sizeof(mi.m_szInstanceUnrestrictedUser), DEFAULT_UNRESTRICTED_USER);
  737. mi.m_nCfgSspt = DEFAULT_CONFIG_SSPT;
  738. my_snprintf(mi.m_szSsptUid, sizeof(mi.m_szSsptUid), DEFAULT_SSPT_USER);
  739. /* stevross: don't want default for these in silent mode, user must specify them */
  740. if( SILENTMODE != MODE)
  741. {
  742. my_snprintf(mi.m_szSupplierDN, sizeof(mi.m_szSupplierDN), DEFAULT_SUPPLIER_DN);
  743. my_snprintf(mi.m_szChangeLogSuffix, sizeof(mi.m_szChangeLogSuffix), DEFAULT_CHANGELOGSUFFIX);
  744. }
  745. /* don't want to use these unless they were asked in dialog, then this flag will be
  746. changed */
  747. mi.m_nSetupSupplierReplication = NO_REPLICATION;
  748. mi.m_nSetupConsumerReplication = NO_REPLICATION;
  749. mi.m_nUseSupplierSettings = 0;
  750. mi.m_nUseChangeLogSettings = 0;
  751. my_strncpy(mi.m_szSIRDays, DEFAULT_SIR_DAYS, sizeof(mi.m_szSIRDays));
  752. my_strncpy(mi.m_szSIRTimes, DEFAULT_SIR_TIMES, sizeof(mi.m_szSIRTimes));
  753. mi.m_nSupplierPort = DEFAULT_SERVER_PORT;
  754. my_strncpy(mi.m_szCIRDays, DEFAULT_CIR_DAYS, sizeof(mi.m_szCIRDays));
  755. my_strncpy(mi.m_szCIRTimes, DEFAULT_CIR_TIMES, sizeof(mi.m_szCIRTimes));
  756. mi.m_nConsumerPort = DEFAULT_SERVER_PORT;
  757. mi.m_nCIRInterval = DEFAULT_CIR_INTERVAL;
  758. /* default MCC settings */
  759. my_strncpy(mi.m_szMCCSuffix, NS_DOMAIN_ROOT, sizeof(mi.m_szMCCSuffix));
  760. mi.m_nMCCPort=DEFAULT_SERVER_PORT;
  761. mi.m_szMCCBindAs = malloc(MAX_STR_SIZE);
  762. my_snprintf(mi.m_szMCCBindAs, MAX_STR_SIZE, "%s", DEFAULT_SSPT_USER);
  763. my_strncpy(mi.m_szUGSuffix, mi.m_szInstanceSuffix, sizeof(mi.m_szUGSuffix));
  764. mi.m_nUGPort=DEFAULT_SERVER_PORT;
  765. my_strncpy(mi.m_szUserGroupAdmin, DEFAULT_UNRESTRICTED_USER, sizeof(mi.m_szUserGroupAdmin));
  766. mi.m_nPopulateSampleEntries = DEFAULT_POPULATE_SAMPLE_ENTRIES;
  767. mi.m_nDisableSchemaChecking = DEFAULT_DISABLE_SCHEMA_CHECKING;
  768. return 0;
  769. }
  770. //////////////////////////////////////////////////////////////////////////////
  771. //
  772. // verify_ldap_settings()
  773. //
  774. // verifys that ldap settings are valid before installing instance
  775. //
  776. //
  777. int verify_ldap_settings()
  778. {
  779. /* XXX stevross: may want to add checks for other things later */
  780. /* for now just make sure port is valid */
  781. if( IsValidNetworkPort( mi.m_nInstanceServerPort ) )
  782. {
  783. return 0;
  784. }else{
  785. DSMessageBoxOK(ERR_SERV_RUN_ON_PORT_TITLE, ERR_SERV_RUN_ON_PORT,
  786. 0, mi.m_nInstanceServerPort);
  787. return -1;
  788. }
  789. }
  790. //////////////////////////////////////////////////////////////////////////////
  791. //
  792. // set_ldap_settings()
  793. //
  794. // registers ldap settings with framework for use by other installers
  795. //
  796. //
  797. void set_ldap_settings()
  798. {
  799. char *utf8MCCHost=NULL;
  800. char *utf8MCCSuffix=NULL;
  801. char *utf8MCCBindAs=NULL;
  802. char *utf8MCCPw=NULL;
  803. char *utf8AdminDomain=NULL;
  804. char szFullAdminDN[MAX_STR_SIZE];
  805. if(1 != mi.m_nExistingMCC && SILENTMODE != MODE)
  806. {
  807. /* this new instance will be MCC, but only copy over things
  808. if not silent mode, in silent mode it will read correct
  809. mcc stuff from the cache */
  810. my_strncpy(mi.m_szMCCHost, mi.m_szInstanceHostName, sizeof(mi.m_szMCCHost));
  811. mi.m_nMCCPort = mi.m_nInstanceServerPort;
  812. my_strncpy(mi.m_szMCCSuffix, NS_DOMAIN_ROOT, sizeof(mi.m_szMCCSuffix));
  813. my_snprintf(mi.m_szMCCBindAs, MAX_STR_SIZE, "%s", mi.m_szSsptUid);
  814. my_strncpy(mi.m_szMCCPw, mi.m_szSsptUidPw, sizeof(mi.m_szMCCPw));
  815. }
  816. /* use existing MCC stuff we read in */
  817. /* convert to UTF8 first for international stuff */
  818. utf8MCCHost = localToUTF8(mi.m_szMCCHost);
  819. utf8MCCSuffix = localToUTF8(mi.m_szMCCSuffix);
  820. utf8MCCBindAs = localToUTF8(mi.m_szMCCBindAs);
  821. utf8MCCPw = localToUTF8(mi.m_szMCCPw);
  822. wsprintf(szFullAdminDN, NS_ADMIN_DOMAIN, mi.m_szAdminDomain);
  823. utf8AdminDomain = localToUTF8(szFullAdminDN);
  824. SetLdapHost(utf8MCCHost);
  825. SetLdapPort(mi.m_nMCCPort);
  826. SetLdapSuffix(utf8MCCSuffix);
  827. SetLdapUser(utf8MCCBindAs);
  828. SetLdapPassword(utf8MCCPw);
  829. SetLdapInstallDN(utf8AdminDomain);
  830. if( utf8MCCHost) nsSetupFree(utf8MCCHost);
  831. if( utf8MCCSuffix) nsSetupFree(utf8MCCSuffix);
  832. if( utf8MCCBindAs) nsSetupFree(utf8MCCBindAs);
  833. if( utf8MCCPw) nsSetupFree(utf8MCCPw);
  834. if( utf8AdminDomain) nsSetupFree(utf8AdminDomain);
  835. }
  836. //////////////////////////////////////////////////////////////////////////////
  837. // _DialogProcs
  838. //
  839. // The dialog procedure for a single property page. You will need to create
  840. // one of these for each property page used in the property sheet. This
  841. // procedure processes dialog messages sent to your property page by Windows.
  842. // See the Windows SDK documentation for more information about this function.
  843. //
  844. /////////////////////////////////////////////////////////////////////////////
  845. // Setup8bitInputDisplay
  846. //
  847. // sets up dialog components to handle 8bit entry/display for I18n requirement
  848. //
  849. //
  850. //
  851. void Setup8bitInputDisplay(HWND hwndDlg, INT hControls[])
  852. {
  853. INT i;
  854. for(i=0; hControls[i] != -1; i++)
  855. {
  856. SendDlgItemMessage (hwndDlg, hControls[i], WM_SETFONT,
  857. (WPARAM) GetStockObject(DEFAULT_GUI_FONT) , MAKELPARAM(TRUE, 0));
  858. }
  859. }
  860. /////////////////////////////////////////////////////////////////////////////
  861. // EnableControls
  862. //
  863. // toggles editable state of Fields
  864. //
  865. //
  866. //
  867. BOOL EnableControls(INT Controls[], HWND hwndDlg, BOOL bEnable)
  868. {
  869. INT i;
  870. HWND hControl;
  871. for(i=0; Controls[i] != -1; i++)
  872. {
  873. hControl = GetDlgItem(hwndDlg, Controls[i]);
  874. EnableWindow(hControl, bEnable);
  875. }
  876. return TRUE;
  877. }
  878. //////////////////////////////////////////////////////////////////////////////
  879. // EnableLDAPURLSettingsFields
  880. //
  881. // toggles editable state of MCC Settings Fields
  882. //
  883. //
  884. //
  885. BOOL EnableLDAPURLSettingsFields(HWND hwndDlg, BOOL bEnable)
  886. {
  887. INT LDAPURL_Controls[]={IDC_EDIT_HOST,
  888. IDC_EDIT_PORT,
  889. IDC_EDIT_SUFFIX,
  890. IDC_EDIT_BIND_AS,
  891. IDC_EDIT_PW, -1};
  892. EnableControls(LDAPURL_Controls, hwndDlg, bEnable);
  893. return TRUE;
  894. }
  895. //////////////////////////////////////////////////////////////////////////////
  896. // EnableConsumerDNFields
  897. //
  898. // toggles editable state of Consumer DN Fields
  899. //
  900. //
  901. //
  902. BOOL EnableConsumerDNFields(HWND hwndDlg, BOOL bEnable)
  903. {
  904. INT Consumer_DN_Controls[]={IDC_EDIT_CONSUMER_DN,
  905. IDC_EDIT_PASSWORD,
  906. IDC_EDIT_PASSWORD_AGAIN,
  907. -1};
  908. EnableControls(Consumer_DN_Controls, hwndDlg, bEnable);
  909. return TRUE;
  910. }
  911. //////////////////////////////////////////////////////////////////////////////
  912. //
  913. // SaveDlgServerInfo
  914. //
  915. // Gets host, port, suffix, bind as, pw from dialog
  916. // used for MCC Settings, UG Settings, Replication Agreement Dialogs
  917. //
  918. void SaveDlgServerInfo(HWND hwndDlg,
  919. PSZ pszHost,
  920. INT *pnPort,
  921. PSZ pszSuffix,
  922. PSZ pszBindAs,
  923. PSZ pszPw)
  924. {
  925. BOOL bTrans;
  926. GetDlgItemText(hwndDlg,
  927. IDC_EDIT_HOST,
  928. pszHost,
  929. MAX_STR_SIZE);
  930. *pnPort = GetDlgItemInt(hwndDlg,
  931. IDC_EDIT_PORT,
  932. &bTrans,
  933. FALSE);
  934. GetDlgItemText(hwndDlg,
  935. IDC_EDIT_SUFFIX,
  936. pszSuffix,
  937. MAX_STR_SIZE);
  938. GetDlgItemText(hwndDlg,
  939. IDC_EDIT_BIND_AS,
  940. pszBindAs,
  941. MAX_STR_SIZE);
  942. GetDlgItemText(hwndDlg,
  943. IDC_EDIT_PW,
  944. pszPw,
  945. MAX_STR_SIZE);
  946. }
  947. //////////////////////////////////////////////////////////////////////////////
  948. //
  949. // LoadDlgServerInfo
  950. //
  951. // Sets host, port, suffix, bind as, pw from dialog
  952. // used for MCC Settings, UG Settings, Replication Agreement Dialogs
  953. //
  954. void LoadDlgServerInfo(HWND hwndDlg,
  955. PSZ pszHost,
  956. INT nPort,
  957. PSZ pszSuffix,
  958. PSZ pszBindAs,
  959. PSZ pszPw)
  960. {
  961. BOOL bResult;
  962. bResult = SetDlgItemText(hwndDlg,
  963. IDC_EDIT_HOST,
  964. pszHost);
  965. if(FALSE == bResult)
  966. {
  967. DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
  968. }
  969. bResult = SetDlgItemInt(hwndDlg,
  970. IDC_EDIT_PORT,
  971. nPort,
  972. TRUE);
  973. if(FALSE == bResult)
  974. {
  975. DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
  976. }
  977. bResult = SetDlgItemText(hwndDlg,
  978. IDC_EDIT_SUFFIX,
  979. pszSuffix);
  980. if(FALSE == bResult)
  981. {
  982. DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
  983. }
  984. bResult = SetDlgItemText(hwndDlg,
  985. IDC_EDIT_BIND_AS,
  986. pszBindAs);
  987. if(FALSE == bResult)
  988. {
  989. DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
  990. }
  991. bResult = SetDlgItemText(hwndDlg,
  992. IDC_EDIT_PW,
  993. pszPw);
  994. if(FALSE == bResult)
  995. {
  996. DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
  997. }
  998. }
  999. //////////////////////////////////////////////////////////////////////////////
  1000. // VerifyServerInfo
  1001. //
  1002. // verifies Server settings are ok
  1003. //
  1004. // Returns TRUE if there is an invalid setting
  1005. // Returns FALSE if all settings are valid
  1006. //
  1007. // SideEffect: displays error (or writes to log in silent mode)
  1008. BOOL VerifyServerInfo( PSZ pszHost,
  1009. INT *pnPort,
  1010. PSZ pszSuffix,
  1011. PSZ pszBindAs,
  1012. PSZ pszPw,
  1013. BOOL bVerifyBindAs)
  1014. {
  1015. BOOL bValueReturned = TRUE;
  1016. if ( 0 == strlen( pszHost) )
  1017. {
  1018. DSMessageBoxOK(ERR_NO_HOST_TITLE, ERR_NO_HOST, 0);
  1019. } else if ( 0 == *pnPort )
  1020. {
  1021. DSMessageBoxOK(ERR_NO_PORT_TITLE, ERR_NO_PORT, 0);
  1022. } else if ( 0 == strlen( pszSuffix) )
  1023. {
  1024. DSMessageBoxOK(ERR_NO_SUFFIX_TITLE, ERR_NO_SUFFIX, 0);
  1025. } else if ( !isValidDN(pszSuffix) )
  1026. {
  1027. /* error message displayed by isvalidDN */
  1028. } else if ( 0 == strlen( pszBindAs) )
  1029. {
  1030. DSMessageBoxOK(ERR_NO_BIND_DN_TITLE, ERR_NO_BIND_DN, 0);
  1031. }else if ( 0 == strlen( pszPw) )
  1032. {
  1033. DSMessageBoxOK(ERR_NO_PW_TITLE, ERR_NO_PW, 0);
  1034. } else if (contains8BitChars(pszPw) )
  1035. {
  1036. DSMessageBoxOK(ERR_8BIT_PW_TITLE, ERR_8BIT_PW, 0);
  1037. } else
  1038. {
  1039. /* all settings look good */
  1040. bValueReturned = FALSE;
  1041. }
  1042. /* try to verify valid dn if need to and no
  1043. previous invalid fields */
  1044. if( !bValueReturned && bVerifyBindAs )
  1045. {
  1046. /* error message displayed by isvalidDN */
  1047. if ( !isValidDN(pszBindAs) )
  1048. {
  1049. /* dn is invalid return true from here */
  1050. bValueReturned = TRUE;
  1051. }
  1052. }
  1053. return bValueReturned;
  1054. }
  1055. //////////////////////////////////////////////////////////////////////////////
  1056. // SaveDialogInput_MCC_Settings
  1057. //
  1058. // save MCC settings entered on Dialog on back and next
  1059. //
  1060. //
  1061. //
  1062. void SaveDialogInput_MCC_Settings(HWND hwndDlg)
  1063. {
  1064. if( 1 == mi.m_nExistingMCC )
  1065. {
  1066. SaveDlgServerInfo(hwndDlg,
  1067. mi.m_szMCCHost,
  1068. &mi.m_nMCCPort,
  1069. mi.m_szMCCSuffix,
  1070. mi.m_szMCCBindAs,
  1071. mi.m_szMCCPw);
  1072. }
  1073. }
  1074. //////////////////////////////////////////////////////////////////////////////
  1075. // VerifyDialogInput_MCC_Settings
  1076. //
  1077. // verify MCC settings entered on Dialog on back and next
  1078. //
  1079. //
  1080. // Returns TRUE if there is an invalid setting
  1081. // Returns FALSE if all settings are valid
  1082. //
  1083. // SideEffect: displays error (or writes to log in silent mode)
  1084. BOOL Verify_MCC_Settings()
  1085. {
  1086. BOOL bValueReturned = FALSE;
  1087. /* only check if configuring to use existing MCC */
  1088. if (1 == mi.m_nExistingMCC)
  1089. {
  1090. if( FALSE == ( bValueReturned = VerifyServerInfo(mi.m_szMCCHost,
  1091. &mi.m_nMCCPort,
  1092. mi.m_szMCCSuffix,
  1093. mi.m_szMCCBindAs,
  1094. mi.m_szMCCPw,
  1095. FALSE) ) )
  1096. {
  1097. /* server info ok, now check rest of the settigns */
  1098. if (FALSE == FullyQualifyHostName(mi.m_szMCCHost) )
  1099. {
  1100. /* can't qualify host name, must be invalid */
  1101. DSMessageBoxOK(ERR_INVALID_HOST_TITLE, ERR_INVALID_HOST,
  1102. mi.m_szMCCHost, mi.m_szMCCHost);
  1103. bValueReturned = TRUE;
  1104. } else
  1105. {
  1106. /* now that all settings entered, check to see if valid user */
  1107. if (FALSE == (UTF8IsValidLdapUser( mi.m_szMCCHost,
  1108. mi.m_nMCCPort,
  1109. mi.m_szMCCSuffix,
  1110. mi.m_szMCCBindAs,
  1111. mi.m_szMCCPw,
  1112. FALSE) ) )
  1113. {
  1114. DSMessageBoxOK(ERR_CANT_FIND_DS_TITLE,
  1115. ERR_CANT_FIND_DS, 0,
  1116. mi.m_szMCCHost,
  1117. mi.m_nMCCPort,
  1118. mi.m_szMCCBindAs);
  1119. bValueReturned = TRUE;
  1120. }
  1121. /* now that all settings entered, find admin domain */
  1122. else if ((CUSTOMMODE != MODE) &&
  1123. (FALSE == (UTF8IsValidAdminDomain( mi.m_szMCCHost,
  1124. mi.m_nMCCPort,
  1125. mi.m_szMCCSuffix,
  1126. mi.m_szAdminDomain,
  1127. mi.m_szMCCBindAs,
  1128. mi.m_szMCCPw) ) ) )
  1129. {
  1130. DSMessageBoxOK(ERR_CANT_FIND_ADMIN_DOMAIN_TITLE,
  1131. ERR_CANT_FIND_ADMIN_DOMAIN, mi.m_szAdminDomain,
  1132. mi.m_szAdminDomain,
  1133. mi.m_szMCCHost,
  1134. mi.m_nMCCPort,
  1135. mi.m_szMCCBindAs);
  1136. bValueReturned = TRUE;
  1137. }
  1138. /* all settings good */
  1139. /* don't want to cfg sspt if already have mcc user */
  1140. mi.m_nCfgSspt = 0;
  1141. }
  1142. }
  1143. }
  1144. return bValueReturned;
  1145. }
  1146. //////////////////////////////////////////////////////////////////////////////
  1147. // MCC_Settings_DialogProc
  1148. //
  1149. // dialog proc to choose MCC server settings
  1150. //
  1151. //
  1152. //
  1153. static BOOL CALLBACK
  1154. MCC_Settings_DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  1155. {
  1156. BOOL bValueReturned = FALSE;
  1157. UINT uResult = 0;
  1158. BOOL bResult = FALSE;
  1159. /* list of controls to be setup for 8bit input/display */
  1160. INT h8bitControls[]={IDC_EDIT_HOST,
  1161. IDC_EDIT_SUFFIX,
  1162. IDC_EDIT_BIND_AS,
  1163. IDC_EDIT_PW, -1};
  1164. switch (uMsg)
  1165. {
  1166. case WM_INITDIALOG:
  1167. // This message is sent when the property page is first created. Here
  1168. // you can perform any one time initialization that you require.
  1169. Setup8bitInputDisplay(hwndDlg, h8bitControls);
  1170. ShowWindow(GetDlgItem(hwndDlg, IDC_EDIT_SUFFIX), FALSE);
  1171. ShowWindow(GetDlgItem(hwndDlg, IDC_STATIC_MCC_SUFFIX), FALSE);
  1172. break;
  1173. case WM_COMMAND:
  1174. // Windows sends WM_COMMAND messages whenever the user clicks on
  1175. // a control in your property page. If you need to perform some
  1176. // special action, such as validating data or responding to a
  1177. // button click, do it here.
  1178. if(BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_RADIO_USE_EXISTING_SERVER) )
  1179. {
  1180. EnableLDAPURLSettingsFields(hwndDlg, TRUE);
  1181. mi.m_nExistingMCC = 1;
  1182. }else if(BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_RADIO_USE_THIS_SERVER) ){
  1183. EnableLDAPURLSettingsFields(hwndDlg, FALSE);
  1184. mi.m_nExistingMCC = 0;
  1185. }
  1186. break;
  1187. case WM_NOTIFY:
  1188. // Windows sends WM_NOTIFY messages to your property page whenever
  1189. // something interesting happens to the page. This could be page
  1190. // activation/deactivation, a button click, etc. The wParam parameter
  1191. // contains a pointer to the property page. The lParam parameter
  1192. // contains a pointer to an NMHDR structure. The code field of this
  1193. // structure contains the notification message code being sent. The
  1194. // property sheet API allows you to alter the behavior of these
  1195. // messages by returning a value for each message. To return a value,
  1196. // use the SetWindowLong Windows SDK function.
  1197. switch (((NMHDR*)lParam)->code)
  1198. {
  1199. case PSN_SETACTIVE:
  1200. // This notification is sent upon activation of the property page.
  1201. // The property sheet should be centered each time it is activated
  1202. // in case the user has moved the stupid thing (this duplicates
  1203. // InstallShield functionality). You should also set the state of
  1204. // the wizard buttons here.
  1205. //
  1206. // NOTE: If you do not wish this page to become active, return -1.
  1207. LoadDlgServerInfo(hwndDlg,
  1208. mi.m_szMCCHost,
  1209. mi.m_nMCCPort,
  1210. mi.m_szMCCSuffix,
  1211. mi.m_szMCCBindAs,
  1212. mi.m_szMCCPw);
  1213. CheckRadioButton(hwndDlg, IDC_RADIO_USE_THIS_SERVER,
  1214. IDC_RADIO_USE_EXISTING_SERVER,
  1215. ( (1 == mi.m_nExistingMCC) ? IDC_RADIO_USE_EXISTING_SERVER :
  1216. IDC_RADIO_USE_THIS_SERVER));
  1217. if(1 == mi.m_nExistingMCC)
  1218. {
  1219. EnableLDAPURLSettingsFields(hwndDlg, TRUE);
  1220. }else{
  1221. EnableLDAPURLSettingsFields(hwndDlg, FALSE);
  1222. }
  1223. CenterWindow(GetParent(hwndDlg));
  1224. PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
  1225. break;
  1226. case PSN_KILLACTIVE:
  1227. // This notification is sent upon deactivation of the property page.
  1228. // Here you can do whatever might be necessary for this action, such
  1229. // as saving the state of the controls. You should also reset the
  1230. // the state of the wizard buttons here, as both the Back and Next
  1231. // buttons should be active when you leave the AskOptions function.
  1232. //
  1233. // NOTE: If you do not want the page deactivated, return -1.
  1234. PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
  1235. break;
  1236. case PSN_WIZBACK:
  1237. // The user clicked the back button from the first property page.
  1238. // Set the result code NS_WIZBACK to indicate this action and close
  1239. // the property sheet using brute force. If this procedure is not
  1240. // being used by the first property sheet, you should ignore this
  1241. // notification and simply let windows go to the previous page.
  1242. //
  1243. // NOTE: To prevent the wizard from stepping back, return -1.
  1244. SaveDialogInput_MCC_Settings(hwndDlg);
  1245. /* first dialog, so send wizback to previous module */
  1246. mi.m_nResult = NS_WIZBACK;
  1247. SendMessage(GetParent(hwndDlg), WM_CLOSE, 0, 0);
  1248. break;
  1249. case PSN_WIZNEXT:
  1250. // The user clicked the next button from the last property page.
  1251. // Set the result code NS_WIZNEXT to indicate this action and close
  1252. // the property sheet using brute force. If this procedure is not
  1253. // being used by the last property sheet, you should ignore this
  1254. // notification and simply let windows go to the next page.
  1255. //
  1256. // NOTE: To prevent the wizard from stepping ahead, return -1.
  1257. SaveDialogInput_MCC_Settings(hwndDlg);
  1258. if( TRUE == (bValueReturned = Verify_MCC_Settings() ) )
  1259. {
  1260. // one of the settings was invalid so stay on this page
  1261. SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
  1262. }
  1263. break;
  1264. case PSN_QUERYCANCEL:
  1265. // This notification is sent when the user clicks the Cancel button.
  1266. // It is also sent in response to the WM_CLOSE messages issued
  1267. // by PSN_WIZBACK and PSN_WIZNEXT. Make sure that we only process
  1268. // this message if the result is not back or next so that we don't
  1269. // nuke the return value assigned by PSN_WIZBACK or PSN_WIZNEXT.
  1270. //
  1271. // NOTE: To prevent the cancel from occuring, return -1.
  1272. if (mi.m_nResult != NS_WIZBACK && mi.m_nResult != NS_WIZNEXT)
  1273. {
  1274. if (QueryExit(hwndDlg))
  1275. {
  1276. mi.m_nResult = NS_WIZCANCEL;
  1277. }
  1278. else
  1279. {
  1280. SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
  1281. bValueReturned = TRUE;
  1282. }
  1283. }
  1284. break;
  1285. }
  1286. break;
  1287. }
  1288. return bValueReturned;
  1289. }
  1290. //////////////////////////////////////////////////////////////////////////////
  1291. //
  1292. // SaveDialogInput_ReInstall
  1293. //
  1294. // saves settings entered in ReInstall Dlg
  1295. //
  1296. void SaveDialogInput_ReInstall(HWND hwndDlg)
  1297. {
  1298. GetDlgItemText(hwndDlg,
  1299. IDC_EDIT_BIND_AS,
  1300. mi.m_szMCCBindAs,
  1301. MAX_STR_SIZE);
  1302. GetDlgItemText(hwndDlg,
  1303. IDC_EDIT_PW,
  1304. mi.m_szMCCPw,
  1305. MAX_STR_SIZE);
  1306. }
  1307. //////////////////////////////////////////////////////////////////////////////
  1308. // Verify_ReInstall
  1309. //
  1310. // verify ReInstall settings entered on Dialog on back and next
  1311. //
  1312. //
  1313. // Returns TRUE if there is an invalid setting
  1314. // Returns FALSE if all settings are valid
  1315. //
  1316. // SideEffect: displays error (or writes to log in silent mode)
  1317. BOOL Verify_ReInstall()
  1318. {
  1319. BOOL bValueReturned = FALSE;
  1320. /* Get URL components so we can verify all MCC settings */
  1321. if( GetURLComponents(mi.m_szLdapURL, mi.m_szMCCHost,
  1322. &mi.m_nMCCPort, mi.m_szMCCSuffix) != 0)
  1323. {
  1324. /* error Getting URL Components*/
  1325. DSMessageBoxOK(ERR_NO_CONFIG_URL_TITLE, ERR_NO_CONFIG_URL, 0);
  1326. bValueReturned = TRUE;
  1327. }else{
  1328. /* since we have all MCC info,
  1329. pass it thorugh Verify_MCC_Settings
  1330. to do all the same verifications.*/
  1331. /* set this to one so MCC Settings get checked */
  1332. mi.m_nExistingMCC = 1;
  1333. bValueReturned = Verify_MCC_Settings();
  1334. }
  1335. return bValueReturned;
  1336. }
  1337. //////////////////////////////////////////////////////////////////////////////
  1338. // ReInstall Dialog Proc
  1339. //
  1340. // ask configuration information needed on reinstall
  1341. //
  1342. //
  1343. //
  1344. //
  1345. static BOOL CALLBACK
  1346. ReInstall_DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  1347. {
  1348. BOOL bValueReturned = FALSE;
  1349. UINT uResult = 0;
  1350. BOOL bResult = FALSE;
  1351. /* list of controls to be setup for 8bit input/display */
  1352. INT h8bitControls[]={IDC_EDIT_BIND_AS,
  1353. -1};
  1354. switch (uMsg)
  1355. {
  1356. case WM_INITDIALOG:
  1357. // This message is sent when the property page is first created. Here
  1358. // you can perform any one time initialization that you require.
  1359. Setup8bitInputDisplay(hwndDlg, h8bitControls);
  1360. break;
  1361. case WM_COMMAND:
  1362. // Windows sends WM_COMMAND messages whenever the user clicks on
  1363. // a control in your property page. If you need to perform some
  1364. // special action, such as validating data or responding to a
  1365. // button click, do it here.
  1366. break;
  1367. case WM_NOTIFY:
  1368. // Windows sends WM_NOTIFY messages to your property page whenever
  1369. // something interesting happens to the page. This could be page
  1370. // activation/deactivation, a button click, etc. The wParam parameter
  1371. // contains a pointer to the property page. The lParam parameter
  1372. // contains a pointer to an NMHDR structure. The code field of this
  1373. // structure contains the notification message code being sent. The
  1374. // property sheet API allows you to alter the behavior of these
  1375. // messages by returning a value for each message. To return a value,
  1376. // use the SetWindowLong Windows SDK function.
  1377. switch (((NMHDR*)lParam)->code)
  1378. {
  1379. char * szLdapUrl;
  1380. case PSN_SETACTIVE:
  1381. // This notification is sent upon activation of the property page.
  1382. // The property sheet should be centered each time it is activated
  1383. // in case the user has moved the stupid thing (this duplicates
  1384. // InstallShield functionality). You should also set the state of
  1385. // the wizard buttons here.
  1386. //
  1387. // NOTE: If you do not wish this page to become active, return -1.
  1388. /* This dialog is displayed in the following ways */
  1389. /* Creating MCC Custom & normal mode ( after MCC admin page) */
  1390. /* or */
  1391. /* Using existing MCC Custom Mode Only (after MCC Settings Page ) */
  1392. szLdapUrl = stripConfigLdapURL(mi.m_szLdapURL);
  1393. bResult = SetDlgItemText(hwndDlg,
  1394. IDC_CONFIG_URL_VAL,
  1395. szLdapUrl);
  1396. if(FALSE == bResult)
  1397. {
  1398. DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
  1399. }
  1400. bResult = SetDlgItemText(hwndDlg,
  1401. IDC_EDIT_BIND_AS,
  1402. mi.m_szMCCBindAs);
  1403. if(FALSE == bResult)
  1404. {
  1405. DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
  1406. }
  1407. bResult = SetDlgItemText(hwndDlg,
  1408. IDC_EDIT_PW,
  1409. mi.m_szMCCPw);
  1410. if(FALSE == bResult)
  1411. {
  1412. DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
  1413. }
  1414. CenterWindow(GetParent(hwndDlg));
  1415. PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
  1416. break;
  1417. case PSN_KILLACTIVE:
  1418. // This notification is sent upon deactivation of the property page.
  1419. // Here you can do whatever might be necessary for this action, such
  1420. // as saving the state of the controls. You should also reset the
  1421. // the state of the wizard buttons here, as both the Back and Next
  1422. // buttons should be active when you leave the AskOptions function.
  1423. //
  1424. // NOTE: If you do not want the page deactivated, return -1.
  1425. PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
  1426. break;
  1427. case PSN_WIZBACK:
  1428. // The user clicked the back button from the first property page.
  1429. // Set the result code NS_WIZBACK to indicate this action and close
  1430. // the property sheet using brute force. If this procedure is not
  1431. // being used by the first property sheet, you should ignore this
  1432. // notification and simply let windows go to the previous page.
  1433. //
  1434. // NOTE: To prevent the wizard from stepping back, return -1.
  1435. SaveDialogInput_ReInstall(hwndDlg);
  1436. // this is only dialog, so set back to go to other module */
  1437. mi.m_nResult = NS_WIZBACK;
  1438. SendMessage(GetParent(hwndDlg), WM_CLOSE, 0, 0);
  1439. break;
  1440. case PSN_WIZNEXT:
  1441. // The user clicked the next button from the last property page.
  1442. // Set the result code NS_WIZNEXT to indicate this action and close
  1443. // the property sheet using brute force. If this procedure is not
  1444. // being used by the last property sheet, you should ignore this
  1445. // notification and simply let windows go to the next page.
  1446. //
  1447. // NOTE: To prevent the wizard from stepping ahead, return -1.
  1448. SaveDialogInput_ReInstall(hwndDlg);
  1449. if (TRUE == (bValueReturned = Verify_ReInstall() ) )
  1450. {
  1451. /* setting is invalid stay on this page */
  1452. SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
  1453. }else{
  1454. /* everything looks ok */
  1455. // this is only dialog, so set back to go to other module */
  1456. mi.m_nResult = NS_WIZNEXT;
  1457. SendMessage(GetParent(hwndDlg), WM_CLOSE, 0, 0);
  1458. }
  1459. break;
  1460. case PSN_QUERYCANCEL:
  1461. // This notification is sent when the user clicks the Cancel button.
  1462. // It is also sent in response to the WM_CLOSE messages issued
  1463. // by PSN_WIZBACK and PSN_WIZNEXT. Make sure that we only process
  1464. // this message if the result is not back or next so that we don't
  1465. // nuke the return value assigned by PSN_WIZBACK or PSN_WIZNEXT.
  1466. //
  1467. // NOTE: To prevent the cancel from occuring, return -1.
  1468. if (mi.m_nResult != NS_WIZBACK && mi.m_nResult != NS_WIZNEXT)
  1469. {
  1470. if (QueryExit(hwndDlg))
  1471. {
  1472. mi.m_nResult = NS_WIZCANCEL;
  1473. }
  1474. else
  1475. {
  1476. SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
  1477. bValueReturned = TRUE;
  1478. }
  1479. }
  1480. break;
  1481. }
  1482. break;
  1483. }
  1484. return bValueReturned;
  1485. }
  1486. //////////////////////////////////////////////////////////////////////////////
  1487. //
  1488. // SaveDialogInput_AdminDomain
  1489. //
  1490. //
  1491. // save settings entered in admin domain dialog proc
  1492. //
  1493. //
  1494. void SaveDialogInput_AdminDomain(HWND hwndDlg)
  1495. {
  1496. GetDlgItemText(hwndDlg,
  1497. IDC_EDIT_ADMIN_DOMAIN,
  1498. mi.m_szAdminDomain,
  1499. MAX_STR_SIZE);
  1500. }
  1501. //////////////////////////////////////////////////////////////////////////////
  1502. //
  1503. // Verify_AdminDomain
  1504. //
  1505. //
  1506. // verify and save settings entered in admin domain dialog proc
  1507. //
  1508. // Returns TRUE if there is an invalid setting
  1509. // Returns False if all settings are valid
  1510. //
  1511. // SideEffect: displays error (or writes to log in silent mode)
  1512. BOOL VerifyAdminDomain()
  1513. {
  1514. BOOL bValueReturned = TRUE;
  1515. if(0 == strlen(mi.m_szAdminDomain) )
  1516. {
  1517. DSMessageBoxOK(ERR_NO_ADMIN_DOMAIN_TITLE, ERR_NO_ADMIN_DOMAIN, 0);
  1518. }else if(isAValidDN(mi.m_szAdminDomain) ){
  1519. /* admin domain is not allowed to be a DN, so if it is
  1520. prompt user and return error */
  1521. DSMessageBoxOK(ERR_ADMIN_DOMAIN_DN_TITLE, ERR_ADMIN_DOMAIN_DN,
  1522. mi.m_szAdminDomain, mi.m_szAdminDomain);
  1523. }else if (0 == mi.m_nExistingMCC){
  1524. /* we are creating the Config Directory, so we don't need to check if
  1525. the admin domain is present */
  1526. bValueReturned = FALSE;
  1527. /* now that all settings entered, find admin domain */
  1528. }else if (FALSE == (UTF8IsValidAdminDomain( mi.m_szMCCHost,
  1529. mi.m_nMCCPort,
  1530. mi.m_szMCCSuffix,
  1531. mi.m_szAdminDomain,
  1532. mi.m_szMCCBindAs,
  1533. mi.m_szMCCPw) ) )
  1534. {
  1535. DSMessageBoxOK(ERR_CANT_FIND_ADMIN_DOMAIN_TITLE,
  1536. ERR_CANT_FIND_ADMIN_DOMAIN, mi.m_szAdminDomain,
  1537. mi.m_szAdminDomain,
  1538. mi.m_szMCCHost,
  1539. mi.m_nMCCPort,
  1540. mi.m_szMCCBindAs);
  1541. bValueReturned = TRUE;
  1542. }else{
  1543. /* all settings ok, return false */
  1544. bValueReturned = FALSE;
  1545. }
  1546. return bValueReturned;
  1547. }
  1548. //////////////////////////////////////////////////////////////////////////////
  1549. // Admin Domain Dialog Proc
  1550. //
  1551. // dialog proc to ask for admin domain
  1552. //
  1553. //
  1554. //
  1555. //
  1556. static BOOL CALLBACK
  1557. AdminDomain_DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  1558. {
  1559. BOOL bValueReturned = FALSE;
  1560. UINT uResult = 0;
  1561. BOOL bResult = FALSE;
  1562. /* list of controls to be setup for 8bit input/display */
  1563. INT h8bitControls[]={IDC_EDIT_ADMIN_DOMAIN
  1564. -1};
  1565. switch (uMsg)
  1566. {
  1567. case WM_INITDIALOG:
  1568. // This message is sent when the property page is first created. Here
  1569. // you can perform any one time initialization that you require.
  1570. Setup8bitInputDisplay(hwndDlg, h8bitControls);
  1571. break;
  1572. case WM_COMMAND:
  1573. // Windows sends WM_COMMAND messages whenever the user clicks on
  1574. // a control in your property page. If you need to perform some
  1575. // special action, such as validating data or responding to a
  1576. // button click, do it here.
  1577. break;
  1578. case WM_NOTIFY:
  1579. // Windows sends WM_NOTIFY messages to your property page whenever
  1580. // something interesting happens to the page. This could be page
  1581. // activation/deactivation, a button click, etc. The wParam parameter
  1582. // contains a pointer to the property page. The lParam parameter
  1583. // contains a pointer to an NMHDR structure. The code field of this
  1584. // structure contains the notification message code being sent. The
  1585. // property sheet API allows you to alter the behavior of these
  1586. // messages by returning a value for each message. To return a value,
  1587. // use the SetWindowLong Windows SDK function.
  1588. switch (((NMHDR*)lParam)->code)
  1589. {
  1590. case PSN_SETACTIVE:
  1591. // This notification is sent upon activation of the property page.
  1592. // The property sheet should be centered each time it is activated
  1593. // in case the user has moved the stupid thing (this duplicates
  1594. // InstallShield functionality). You should also set the state of
  1595. // the wizard buttons here.
  1596. //
  1597. // NOTE: If you do not wish this page to become active, return -1.
  1598. /* This dialog is displayed in the following ways */
  1599. /* Creating MCC Custom & normal mode ( after MCC admin page) */
  1600. /* or */
  1601. /* Using existing MCC Custom Mode Only (after MCC Settings Page ) */
  1602. if(1 == mi.m_nExistingMCC )
  1603. {
  1604. /* not creating an MCC so don't ask this page */
  1605. SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
  1606. return TRUE;
  1607. }
  1608. bResult = SetDlgItemText(hwndDlg,
  1609. IDC_EDIT_ADMIN_DOMAIN,
  1610. mi.m_szAdminDomain);
  1611. if(FALSE == bResult)
  1612. {
  1613. DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
  1614. }
  1615. CenterWindow(GetParent(hwndDlg));
  1616. PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
  1617. break;
  1618. case PSN_KILLACTIVE:
  1619. // This notification is sent upon deactivation of the property page.
  1620. // Here you can do whatever might be necessary for this action, such
  1621. // as saving the state of the controls. You should also reset the
  1622. // the state of the wizard buttons here, as both the Back and Next
  1623. // buttons should be active when you leave the AskOptions function.
  1624. //
  1625. // NOTE: If you do not want the page deactivated, return -1.
  1626. PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
  1627. break;
  1628. case PSN_WIZBACK:
  1629. // The user clicked the back button from the first property page.
  1630. // Set the result code NS_WIZBACK to indicate this action and close
  1631. // the property sheet using brute force. If this procedure is not
  1632. // being used by the first property sheet, you should ignore this
  1633. // notification and simply let windows go to the previous page.
  1634. //
  1635. // NOTE: To prevent the wizard from stepping back, return -1.
  1636. SaveDialogInput_AdminDomain(hwndDlg);
  1637. break;
  1638. case PSN_WIZNEXT:
  1639. // The user clicked the next button from the last property page.
  1640. // Set the result code NS_WIZNEXT to indicate this action and close
  1641. // the property sheet using brute force. If this procedure is not
  1642. // being used by the last property sheet, you should ignore this
  1643. // notification and simply let windows go to the next page.
  1644. //
  1645. // NOTE: To prevent the wizard from stepping ahead, return -1.
  1646. SaveDialogInput_AdminDomain(hwndDlg);
  1647. if (TRUE == (bValueReturned = VerifyAdminDomain() ) )
  1648. {
  1649. /* setting is invalid stay on this page */
  1650. SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
  1651. }
  1652. break;
  1653. case PSN_QUERYCANCEL:
  1654. // This notification is sent when the user clicks the Cancel button.
  1655. // It is also sent in response to the WM_CLOSE messages issued
  1656. // by PSN_WIZBACK and PSN_WIZNEXT. Make sure that we only process
  1657. // this message if the result is not back or next so that we don't
  1658. // nuke the return value assigned by PSN_WIZBACK or PSN_WIZNEXT.
  1659. //
  1660. // NOTE: To prevent the cancel from occuring, return -1.
  1661. if (mi.m_nResult != NS_WIZBACK && mi.m_nResult != NS_WIZNEXT)
  1662. {
  1663. if (QueryExit(hwndDlg))
  1664. {
  1665. mi.m_nResult = NS_WIZCANCEL;
  1666. }
  1667. else
  1668. {
  1669. SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
  1670. bValueReturned = TRUE;
  1671. }
  1672. }
  1673. break;
  1674. }
  1675. break;
  1676. }
  1677. return bValueReturned;
  1678. }
  1679. //////////////////////////////////////////////////////////////////////////////
  1680. // Admin Domain Custom Dialog Proc
  1681. //
  1682. // dialog proc to ask for admin domain in custom mode when we are installing
  1683. // into existing MCC
  1684. //
  1685. // basically the same as Admin Domain with some added code to lookup domain
  1686. // kind of lame to duplicate code, but this was the best way to get flow to match unix
  1687. //
  1688. static BOOL CALLBACK
  1689. AdminDomainCustom_DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  1690. {
  1691. BOOL bValueReturned = FALSE;
  1692. UINT uResult = 0;
  1693. BOOL bResult = FALSE;
  1694. /* list of controls to be setup for 8bit input/display */
  1695. INT h8bitControls[]={IDC_EDIT_ADMIN_DOMAIN
  1696. -1};
  1697. switch (uMsg)
  1698. {
  1699. case WM_INITDIALOG:
  1700. // This message is sent when the property page is first created. Here
  1701. // you can perform any one time initialization that you require.
  1702. Setup8bitInputDisplay(hwndDlg, h8bitControls);
  1703. break;
  1704. case WM_COMMAND:
  1705. // Windows sends WM_COMMAND messages whenever the user clicks on
  1706. // a control in your property page. If you need to perform some
  1707. // special action, such as validating data or responding to a
  1708. // button click, do it here.
  1709. break;
  1710. case WM_NOTIFY:
  1711. // Windows sends WM_NOTIFY messages to your property page whenever
  1712. // something interesting happens to the page. This could be page
  1713. // activation/deactivation, a button click, etc. The wParam parameter
  1714. // contains a pointer to the property page. The lParam parameter
  1715. // contains a pointer to an NMHDR structure. The code field of this
  1716. // structure contains the notification message code being sent. The
  1717. // property sheet API allows you to alter the behavior of these
  1718. // messages by returning a value for each message. To return a value,
  1719. // use the SetWindowLong Windows SDK function.
  1720. switch (((NMHDR*)lParam)->code)
  1721. {
  1722. case PSN_SETACTIVE:
  1723. // This notification is sent upon activation of the property page.
  1724. // The property sheet should be centered each time it is activated
  1725. // in case the user has moved the stupid thing (this duplicates
  1726. // InstallShield functionality). You should also set the state of
  1727. // the wizard buttons here.
  1728. //
  1729. // NOTE: If you do not wish this page to become active, return -1.
  1730. /* This dialog is displayed in the following ways */
  1731. /* Creating MCC Custom & normal mode ( after MCC admin page) */
  1732. /* or */
  1733. /* Using existing MCC Custom Mode Only (after MCC Settings Page ) */
  1734. /* only display this page in Custom Mode if installing into existing MCC */
  1735. if( (0 == mi.m_nExistingMCC) || CUSTOMMODE != MODE)
  1736. {
  1737. /* dont display this page */
  1738. SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
  1739. return TRUE;
  1740. }
  1741. /* since we are installing into existing mcc we can search it for admin domains */
  1742. /* stevross: add code to search for admin domains here */
  1743. bResult = SetDlgItemText(hwndDlg,
  1744. IDC_EDIT_ADMIN_DOMAIN,
  1745. mi.m_szAdminDomain);
  1746. if(FALSE == bResult)
  1747. {
  1748. DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
  1749. }
  1750. CenterWindow(GetParent(hwndDlg));
  1751. PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
  1752. break;
  1753. case PSN_KILLACTIVE:
  1754. // This notification is sent upon deactivation of the property page.
  1755. // Here you can do whatever might be necessary for this action, such
  1756. // as saving the state of the controls. You should also reset the
  1757. // the state of the wizard buttons here, as both the Back and Next
  1758. // buttons should be active when you leave the AskOptions function.
  1759. //
  1760. // NOTE: If you do not want the page deactivated, return -1.
  1761. PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
  1762. break;
  1763. case PSN_WIZBACK:
  1764. // The user clicked the back button from the first property page.
  1765. // Set the result code NS_WIZBACK to indicate this action and close
  1766. // the property sheet using brute force. If this procedure is not
  1767. // being used by the first property sheet, you should ignore this
  1768. // notification and simply let windows go to the previous page.
  1769. //
  1770. // NOTE: To prevent the wizard from stepping back, return -1.
  1771. SaveDialogInput_AdminDomain(hwndDlg);
  1772. break;
  1773. case PSN_WIZNEXT:
  1774. // The user clicked the next button from the last property page.
  1775. // Set the result code NS_WIZNEXT to indicate this action and close
  1776. // the property sheet using brute force. If this procedure is not
  1777. // being used by the last property sheet, you should ignore this
  1778. // notification and simply let windows go to the next page.
  1779. //
  1780. // NOTE: To prevent the wizard from stepping ahead, return -1.
  1781. SaveDialogInput_AdminDomain(hwndDlg);
  1782. if (TRUE == (bValueReturned = VerifyAdminDomain() ) )
  1783. {
  1784. /* setting is invalid stay on this page */
  1785. SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
  1786. }
  1787. break;
  1788. case PSN_QUERYCANCEL:
  1789. // This notification is sent when the user clicks the Cancel button.
  1790. // It is also sent in response to the WM_CLOSE messages issued
  1791. // by PSN_WIZBACK and PSN_WIZNEXT. Make sure that we only process
  1792. // this message if the result is not back or next so that we don't
  1793. // nuke the return value assigned by PSN_WIZBACK or PSN_WIZNEXT.
  1794. //
  1795. // NOTE: To prevent the cancel from occuring, return -1.
  1796. if (mi.m_nResult != NS_WIZBACK && mi.m_nResult != NS_WIZNEXT)
  1797. {
  1798. if (QueryExit(hwndDlg))
  1799. {
  1800. mi.m_nResult = NS_WIZCANCEL;
  1801. }
  1802. else
  1803. {
  1804. SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
  1805. bValueReturned = TRUE;
  1806. }
  1807. }
  1808. break;
  1809. }
  1810. break;
  1811. }
  1812. return bValueReturned;
  1813. }
  1814. //////////////////////////////////////////////////////////////////////////////
  1815. //
  1816. // SaveDialogInput_UG_Settings(HWND hwndDlg)
  1817. //
  1818. // Save values entered in UG dialog on back and next
  1819. //
  1820. //
  1821. void SaveDialogInput_UG_Settings(HWND hwndDlg)
  1822. {
  1823. if (1 == mi.m_nExistingUG)
  1824. {
  1825. SaveDlgServerInfo(hwndDlg,
  1826. mi.m_szUGHost,
  1827. &mi.m_nUGPort,
  1828. mi.m_szUGSuffix,
  1829. mi.m_szUserGroupAdmin,
  1830. mi.m_szUserGroupAdminPW);
  1831. }
  1832. }
  1833. //////////////////////////////////////////////////////////////////////////////
  1834. //
  1835. // Verify_UG_Settings()
  1836. //
  1837. // verify values entered in UG dialog on back and next
  1838. //
  1839. //
  1840. BOOL Verify_UG_Settings()
  1841. {
  1842. BOOL bValueReturned = FALSE;
  1843. /* only verify if installing into existing UG */
  1844. if (1 == mi.m_nExistingUG)
  1845. {
  1846. bValueReturned = VerifyServerInfo(mi.m_szUGHost,
  1847. &mi.m_nUGPort,
  1848. mi.m_szUGSuffix,
  1849. mi.m_szUserGroupAdmin,
  1850. mi.m_szUserGroupAdminPW,
  1851. FALSE);
  1852. if (FALSE == bValueReturned)
  1853. {
  1854. /* server info looks ok, now check the rest of the stuff */
  1855. if (FALSE == FullyQualifyHostName(mi.m_szUGHost) )
  1856. {
  1857. /* failed to fully qualify host name */
  1858. DSMessageBoxOK(ERR_INVALID_HOST_TITLE,
  1859. ERR_INVALID_HOST,
  1860. mi.m_szUGHost, mi.m_szUGHost);
  1861. bValueReturned = TRUE;
  1862. } else
  1863. {
  1864. /* now that all settings entered, check to see if valid user */
  1865. if (FALSE == UTF8IsValidLdapUser(mi.m_szUGHost, mi.m_nUGPort,
  1866. mi.m_szUGSuffix,
  1867. mi.m_szUserGroupAdmin,
  1868. mi.m_szUserGroupAdminPW,
  1869. FALSE) )
  1870. {
  1871. DSMessageBoxOK(ERR_CANT_FIND_DS_TITLE,
  1872. ERR_CANT_FIND_DS, 0, mi.m_szUGHost,
  1873. mi.m_nUGPort, mi.m_szUserGroupAdmin);
  1874. bValueReturned = TRUE;
  1875. } else
  1876. {
  1877. /* all settings good */
  1878. /* set UG LDAP URL */
  1879. my_snprintf(mi.m_szUserGroupURL, sizeof(mi.m_szUserGroupURL), "ldap://%s:%d/%s",
  1880. mi.m_szUGHost, mi.m_nUGPort, mi.m_szUGSuffix);
  1881. }
  1882. }
  1883. }
  1884. }
  1885. return bValueReturned;
  1886. }
  1887. //////////////////////////////////////////////////////////////////////////////
  1888. // UG_Settings_DialogProc
  1889. //
  1890. // dialog proc to choose User Group server settings
  1891. //
  1892. //
  1893. //
  1894. static BOOL CALLBACK
  1895. UG_Settings_DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  1896. {
  1897. BOOL bValueReturned = FALSE;
  1898. UINT uResult = 0;
  1899. BOOL bResult = FALSE;
  1900. CHAR szTemp[MAX_STR_SIZE] = {0};
  1901. /* list of controls to be setup for 8bit input/display */
  1902. INT h8bitControls[]={IDC_EDIT_HOST,
  1903. IDC_EDIT_SUFFIX,
  1904. IDC_EDIT_BIND_AS,
  1905. IDC_EDIT_PW, -1};
  1906. switch (uMsg)
  1907. {
  1908. case WM_INITDIALOG:
  1909. // This message is sent when the property page is first created. Here
  1910. // you can perform any one time initialization that you require.
  1911. Setup8bitInputDisplay(hwndDlg, h8bitControls);
  1912. break;
  1913. case WM_COMMAND:
  1914. // Windows sends WM_COMMAND messages whenever the user clicks on
  1915. // a control in your property page. If you need to perform some
  1916. // special action, such as validating data or responding to a
  1917. // button click, do it here.
  1918. if(BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_RADIO_USE_EXISTING_SERVER) )
  1919. {
  1920. EnableLDAPURLSettingsFields(hwndDlg, TRUE);
  1921. mi.m_nExistingUG = 1;
  1922. }else if(BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_RADIO_USE_THIS_SERVER) ){
  1923. EnableLDAPURLSettingsFields(hwndDlg, FALSE);
  1924. mi.m_nExistingUG = 0;
  1925. }
  1926. break;
  1927. case WM_NOTIFY:
  1928. // Windows sends WM_NOTIFY messages to your property page whenever
  1929. // something interesting happens to the page. This could be page
  1930. // activation/deactivation, a button click, etc. The wParam parameter
  1931. // contains a pointer to the property page. The lParam parameter
  1932. // contains a pointer to an NMHDR structure. The code field of this
  1933. // structure contains the notification message code being sent. The
  1934. // property sheet API allows you to alter the behavior of these
  1935. // messages by returning a value for each message. To return a value,
  1936. // use the SetWindowLong Windows SDK function.
  1937. switch (((NMHDR*)lParam)->code)
  1938. {
  1939. case PSN_SETACTIVE:
  1940. // This notification is sent upon activation of the property page.
  1941. // The property sheet should be centered each time it is activated
  1942. // in case the user has moved the stupid thing (this duplicates
  1943. // InstallShield functionality). You should also set the state of
  1944. // the wizard buttons here.
  1945. //
  1946. // NOTE: If you do not wish this page to become active, return -1.
  1947. /* setup static text with user and group strings */
  1948. /* don't want to show this page if not installing into an existing MCC */
  1949. if( 1 == mi.m_nExistingMCC)
  1950. {
  1951. /* dont display this page */
  1952. SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
  1953. return TRUE;
  1954. }
  1955. LoadString( mi.m_hModule, IDS_UG_DESC, szTemp, MAX_STR_SIZE);
  1956. bResult = SetDlgItemText(hwndDlg,
  1957. IDC_STATIC_DESC,
  1958. szTemp);
  1959. if(FALSE == bResult)
  1960. {
  1961. DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
  1962. }
  1963. LoadString( mi.m_hModule, IDS_UG_GB_DESC, szTemp, MAX_STR_SIZE);
  1964. bResult = SetDlgItemText(hwndDlg,
  1965. IDC_STATIC_SETTINGS,
  1966. szTemp);
  1967. if(FALSE == bResult)
  1968. {
  1969. DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
  1970. }
  1971. LoadString( mi.m_hModule, IDS_UG_RADIO_CREATE, szTemp, MAX_STR_SIZE);
  1972. bResult = SetDlgItemText(hwndDlg,
  1973. IDC_RADIO_USE_THIS_SERVER,
  1974. szTemp);
  1975. if(FALSE == bResult)
  1976. {
  1977. DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
  1978. }
  1979. LoadString( mi.m_hModule, IDS_UG_RADIO_EXIST, szTemp, MAX_STR_SIZE);
  1980. bResult = SetDlgItemText(hwndDlg,
  1981. IDC_RADIO_USE_EXISTING_SERVER,
  1982. szTemp);
  1983. if(FALSE == bResult)
  1984. {
  1985. DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
  1986. }
  1987. /* set defaults for text edit fields in this dialog */
  1988. LoadDlgServerInfo(hwndDlg,
  1989. mi.m_szUGHost,
  1990. mi.m_nUGPort,
  1991. mi.m_szUGSuffix,
  1992. mi.m_szUserGroupAdmin,
  1993. mi.m_szUserGroupAdminPW);
  1994. CheckRadioButton(hwndDlg, IDC_RADIO_USE_THIS_SERVER,
  1995. IDC_RADIO_USE_EXISTING_SERVER,
  1996. ( (1 == mi.m_nExistingUG) ? IDC_RADIO_USE_EXISTING_SERVER :
  1997. IDC_RADIO_USE_THIS_SERVER));
  1998. if(1 == mi.m_nExistingUG)
  1999. {
  2000. EnableLDAPURLSettingsFields(hwndDlg, TRUE);
  2001. }else{
  2002. EnableLDAPURLSettingsFields(hwndDlg, FALSE);
  2003. }
  2004. CenterWindow(GetParent(hwndDlg));
  2005. PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
  2006. break;
  2007. case PSN_KILLACTIVE:
  2008. // This notification is sent upon deactivation of the property page.
  2009. // Here you can do whatever might be necessary for this action, such
  2010. // as saving the state of the controls. You should also reset the
  2011. // the state of the wizard buttons here, as both the Back and Next
  2012. // buttons should be active when you leave the AskOptions function.
  2013. //
  2014. // NOTE: If you do not want the page deactivated, return -1.
  2015. PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
  2016. break;
  2017. case PSN_WIZBACK:
  2018. // The user clicked the back button from the first property page.
  2019. // Set the result code NS_WIZBACK to indicate this action and close
  2020. // the property sheet using brute force. If this procedure is not
  2021. // being used by the first property sheet, you should ignore this
  2022. // notification and simply let windows go to the previous page.
  2023. //
  2024. // NOTE: To prevent the wizard from stepping back, return -1.
  2025. SaveDialogInput_UG_Settings(hwndDlg);
  2026. break;
  2027. case PSN_WIZNEXT:
  2028. // The user clicked the next button from the last property page.
  2029. // Set the result code NS_WIZNEXT to indicate this action and close
  2030. // the property sheet using brute force. If this procedure is not
  2031. // being used by the last property sheet, you should ignore this
  2032. // notification and simply let windows go to the next page.
  2033. //
  2034. // NOTE: To prevent the wizard from stepping ahead, return -1.
  2035. SaveDialogInput_UG_Settings(hwndDlg);
  2036. if(TRUE == (bValueReturned = Verify_UG_Settings() ) )
  2037. {
  2038. /* one of the settings was invalid */
  2039. SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
  2040. }
  2041. break;
  2042. case PSN_QUERYCANCEL:
  2043. // This notification is sent when the user clicks the Cancel button.
  2044. // It is also sent in response to the WM_CLOSE messages issued
  2045. // by PSN_WIZBACK and PSN_WIZNEXT. Make sure that we only process
  2046. // this message if the result is not back or next so that we don't
  2047. // nuke the return value assigned by PSN_WIZBACK or PSN_WIZNEXT.
  2048. //
  2049. // NOTE: To prevent the cancel from occuring, return -1.
  2050. if (mi.m_nResult != NS_WIZBACK && mi.m_nResult != NS_WIZNEXT)
  2051. {
  2052. if (QueryExit(hwndDlg))
  2053. {
  2054. mi.m_nResult = NS_WIZCANCEL;
  2055. }
  2056. else
  2057. {
  2058. SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
  2059. bValueReturned = TRUE;
  2060. }
  2061. }
  2062. break;
  2063. }
  2064. break;
  2065. }
  2066. return bValueReturned;
  2067. }
  2068. //////////////////////////////////////////////////////////////////////////////
  2069. // SaveDialogInput_Server_Settings
  2070. //
  2071. // save settings entered in Server_Setting_DialogProc
  2072. // called on back and next
  2073. //
  2074. //
  2075. //
  2076. void SaveDialogInput_Server_Settings(HWND hwndDlg)
  2077. {
  2078. BOOL bResult = FALSE;
  2079. GetDlgItemText(hwndDlg,
  2080. IDC_EDIT_SERVER_IDENTIFIER,
  2081. mi.m_szServerIdentifier,
  2082. MAX_STR_SIZE);
  2083. /* get the suffix */
  2084. GetDlgItemText(hwndDlg,
  2085. IDC_EDIT_SUFFIX,
  2086. mi.m_szInstanceSuffix,
  2087. MAX_STR_SIZE);
  2088. mi.m_nInstanceServerPort = (int ) GetDlgItemInt(hwndDlg,
  2089. IDC_EDIT_SERVER_PORT,
  2090. &bResult,
  2091. TRUE);
  2092. }
  2093. //////////////////////////////////////////////////////////////////////////////
  2094. // Verify_Server_Settings
  2095. //
  2096. // verify settings entered in Server_Setting_DialogProc
  2097. //
  2098. // Returns TRUE if there is an invalid setting
  2099. // Returns FALSE if all settings are valid
  2100. //
  2101. // SideEffect: displays error (or writes to log in silent mode)
  2102. BOOL Verify_Server_Settings()
  2103. {
  2104. BOOL bValueReturned = TRUE;
  2105. if ( 0 == strlen(mi.m_szServerIdentifier) )
  2106. {
  2107. /* no value entered for server id */
  2108. DSMessageBoxOK(ERR_NO_SERVER_ID_TITLE, ERR_NO_SERVER_ID, 0);
  2109. } else if (FALSE == isValidServerID(mi.m_szServerIdentifier) )
  2110. {
  2111. /* server id is invalid */
  2112. /* error reported by isValidServerID */
  2113. } else if (0 == strlen(mi.m_szInstanceSuffix) && !mi.m_nExistingUG )
  2114. {
  2115. /* ok not to specify suffix when using existing UG hence above
  2116. otherwise it must be specified */
  2117. /* no value entered for suffix */
  2118. DSMessageBoxOK(ERR_NO_SUFFIX_TITLE, ERR_NO_SUFFIX, 0);
  2119. }else if (!mi.m_nExistingUG && !isValidDN(mi.m_szInstanceSuffix) )
  2120. {
  2121. /* don't check dn if ExistingUG since suffix is null */
  2122. /* error message displayed by isValidDN */
  2123. } else if ( !isValidPort(mi.m_nInstanceServerPort))
  2124. {
  2125. /* error displayed by isValidPort */
  2126. }else{
  2127. /* all items in this dialogue look good */
  2128. bValueReturned = FALSE;
  2129. }
  2130. return bValueReturned;
  2131. }
  2132. //////////////////////////////////////////////////////////////////////////////
  2133. // Server_Settings_DialogProc
  2134. //
  2135. // dialog proc to choose server settings
  2136. //
  2137. // used by typical mode
  2138. //
  2139. //
  2140. static BOOL CALLBACK
  2141. Server_Settings_DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  2142. {
  2143. BOOL bValueReturned = FALSE;
  2144. UINT uResult = 0;
  2145. BOOL bResult = FALSE;
  2146. HWND hCtrl;
  2147. /* list of controls to be setup for 8bit input/display */
  2148. INT h8bitControls[]={IDC_EDIT_SERVER_IDENTIFIER,
  2149. IDC_EDIT_SUFFIX,
  2150. -1};
  2151. INT nCmdShow = SW_SHOW;
  2152. static CHAR szSavedSuffix[MAX_STR_SIZE]="\0";
  2153. switch (uMsg)
  2154. {
  2155. case WM_INITDIALOG:
  2156. // This message is sent when the property page is first created. Here
  2157. // you can perform any one time initialization that you require.
  2158. Setup8bitInputDisplay(hwndDlg, h8bitControls);
  2159. SendDlgItemMessage(hwndDlg, IDC_SPIN_SERVER_PORT, UDM_SETBUDDY, (WPARAM)GetDlgItem(hwndDlg, IDC_EDIT_SERVER_PORT), 0);
  2160. SendDlgItemMessage(hwndDlg, IDC_SPIN_SERVER_PORT, UDM_SETRANGE, 0, MAKELONG((short)UD_MAXVAL, (short)1));
  2161. my_strncpy(szSavedSuffix, mi.m_szInstanceSuffix, sizeof(szSavedSuffix));
  2162. break;
  2163. case WM_COMMAND:
  2164. // Windows sends WM_COMMAND messages whenever the user clicks on
  2165. // a control in your property page. If you need to perform some
  2166. // special action, such as validating data or responding to a
  2167. // button click, do it here.
  2168. break;
  2169. case WM_NOTIFY:
  2170. // Windows sends WM_NOTIFY messages to your property page whenever
  2171. // something interesting happens to the page. This could be page
  2172. // activation/deactivation, a button click, etc. The wParam parameter
  2173. // contains a pointer to the property page. The lParam parameter
  2174. // contains a pointer to an NMHDR structure. The code field of this
  2175. // structure contains the notification message code being sent. The
  2176. // property sheet API allows you to alter the behavior of these
  2177. // messages by returning a value for each message. To return a value,
  2178. // use the SetWindowLong Windows SDK function.
  2179. switch (((NMHDR*)lParam)->code)
  2180. {
  2181. case PSN_SETACTIVE:
  2182. // This notification is sent upon activation of the property page.
  2183. // The property sheet should be centered each time it is activated
  2184. // in case the user has moved the stupid thing (this duplicates
  2185. // InstallShield functionality). You should also set the state of
  2186. // the wizard buttons here.
  2187. //
  2188. // NOTE: If you do not wish this page to become active, return -1.
  2189. if(mi.m_nExistingUG)
  2190. {
  2191. /* hide suffix when creating config only directory */
  2192. if( 0 != strlen(mi.m_szInstanceSuffix) )
  2193. {
  2194. my_strncpy(szSavedSuffix, mi.m_szInstanceSuffix, sizeof(szSavedSuffix));
  2195. memset(mi.m_szInstanceSuffix, '\0', MAX_STR_SIZE);
  2196. }
  2197. nCmdShow = SW_HIDE;
  2198. }else{
  2199. my_strncpy(mi.m_szInstanceSuffix, szSavedSuffix, sizeof(mi.m_szInstanceSuffix));
  2200. nCmdShow = SW_SHOW;
  2201. }
  2202. hCtrl = GetDlgItem(hwndDlg, IDC_EDIT_SUFFIX);
  2203. ShowWindow(hCtrl,nCmdShow);
  2204. hCtrl = GetDlgItem(hwndDlg, IDC_STATIC_SUFFIX);
  2205. ShowWindow(hCtrl,nCmdShow);
  2206. bResult = SetDlgItemText(hwndDlg,
  2207. IDC_EDIT_SERVER_IDENTIFIER,
  2208. mi.m_szServerIdentifier);
  2209. if(FALSE == bResult)
  2210. {
  2211. DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
  2212. }
  2213. bResult = SetDlgItemText(hwndDlg,
  2214. IDC_EDIT_SUFFIX,
  2215. mi.m_szInstanceSuffix);
  2216. if(FALSE == bResult)
  2217. {
  2218. DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
  2219. }
  2220. bResult = SetDlgItemInt(hwndDlg,
  2221. IDC_EDIT_SERVER_PORT,
  2222. mi.m_nInstanceServerPort,
  2223. TRUE);
  2224. if(FALSE == bResult)
  2225. {
  2226. DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
  2227. }
  2228. CenterWindow(GetParent(hwndDlg));
  2229. PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
  2230. break;
  2231. case PSN_KILLACTIVE:
  2232. // This notification is sent upon deactivation of the property page.
  2233. // Here you can do whatever might be necessary for this action, such
  2234. // as saving the state of the controls. You should also reset the
  2235. // the state of the wizard buttons here, as both the Back and Next
  2236. // buttons should be active when you leave the AskOptions function.
  2237. //
  2238. // NOTE: If you do not want the page deactivated, return -1.
  2239. PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
  2240. break;
  2241. case PSN_WIZBACK:
  2242. // The user clicked the back button from the first property page.
  2243. // Set the result code NS_WIZBACK to indicate this action and close
  2244. // the property sheet using brute force. If this procedure is not
  2245. // being used by the first property sheet, you should ignore this
  2246. // notification and simply let windows go to the previous page.
  2247. //
  2248. // NOTE: To prevent the wizard from stepping back, return -1.
  2249. SaveDialogInput_Server_Settings(hwndDlg);
  2250. // save the suffix typed in by the user
  2251. my_strncpy(szSavedSuffix, mi.m_szInstanceSuffix, sizeof(szSavedSuffix));
  2252. break;
  2253. case PSN_WIZNEXT:
  2254. // The user clicked the next button from the last property page.
  2255. // Set the result code NS_WIZNEXT to indicate this action and close
  2256. // the property sheet using brute force. If this procedure is not
  2257. // being used by the last property sheet, you should ignore this
  2258. // notification and simply let windows go to the next page.
  2259. //
  2260. // NOTE: To prevent the wizard from stepping ahead, return -1.
  2261. SaveDialogInput_Server_Settings(hwndDlg);
  2262. // save the suffix typed in by the user
  2263. my_strncpy(szSavedSuffix, mi.m_szInstanceSuffix, sizeof(szSavedSuffix));
  2264. if( TRUE == (bValueReturned = Verify_Server_Settings()) )
  2265. {
  2266. /* one of the settings was invalid stay on this page */
  2267. SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
  2268. }
  2269. break;
  2270. case PSN_QUERYCANCEL:
  2271. // This notification is sent when the user clicks the Cancel button.
  2272. // It is also sent in response to the WM_CLOSE messages issued
  2273. // by PSN_WIZBACK and PSN_WIZNEXT. Make sure that we only process
  2274. // this message if the result is not back or next so that we don't
  2275. // nuke the return value assigned by PSN_WIZBACK or PSN_WIZNEXT.
  2276. //
  2277. // NOTE: To prevent the cancel from occuring, return -1.
  2278. if (mi.m_nResult != NS_WIZBACK && mi.m_nResult != NS_WIZNEXT)
  2279. {
  2280. if (QueryExit(hwndDlg))
  2281. {
  2282. mi.m_nResult = NS_WIZCANCEL;
  2283. }
  2284. else
  2285. {
  2286. SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
  2287. bValueReturned = TRUE;
  2288. }
  2289. }
  2290. break;
  2291. }
  2292. break;
  2293. }
  2294. return bValueReturned;
  2295. }
  2296. //////////////////////////////////////////////////////////////////////////////
  2297. // BOOL SaveDialogPasswords
  2298. //
  2299. // helper for ROOTDN and SUITESPOTDN Dialogs
  2300. //
  2301. //
  2302. // saves passwords entered into dialog
  2303. //
  2304. //
  2305. void SaveDialogPasswords(HWND hwndDlg, PSZ pszPassword, PSZ pszPasswordAgain)
  2306. {
  2307. GetDlgItemText(hwndDlg,
  2308. IDC_EDIT_PASSWORD,
  2309. pszPassword,
  2310. MAX_STR_SIZE);
  2311. GetDlgItemText(hwndDlg,
  2312. IDC_EDIT_PASSWORD_AGAIN,
  2313. pszPasswordAgain,
  2314. MAX_STR_SIZE);
  2315. }
  2316. //////////////////////////////////////////////////////////////////////////////
  2317. // BOOL LoadDialogPasswords
  2318. //
  2319. // helper for ROOTDN and SUITESPOTDN Dialogs
  2320. //
  2321. //
  2322. // loads passwords entered into dialog
  2323. //
  2324. //
  2325. void LoadDialogPasswords(HWND hwndDlg, PSZ pszPassword, PSZ pszPasswordAgain)
  2326. {
  2327. BOOL bResult;
  2328. bResult = SetDlgItemText(hwndDlg,
  2329. IDC_EDIT_PASSWORD,
  2330. pszPassword);
  2331. if(FALSE == bResult)
  2332. {
  2333. DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
  2334. }
  2335. if (pszPasswordAgain)
  2336. {
  2337. bResult = SetDlgItemText(hwndDlg,
  2338. IDC_EDIT_PASSWORD_AGAIN,
  2339. pszPasswordAgain);
  2340. if(FALSE == bResult)
  2341. {
  2342. DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
  2343. }
  2344. }
  2345. }
  2346. //////////////////////////////////////////////////////////////////////////////
  2347. // BOOL VerifyPasswords
  2348. //
  2349. // helper for ROOTDN and SUITESPOTDN Dialogs
  2350. //
  2351. //
  2352. // check that passwords are valid
  2353. //
  2354. // Returns TRUE if there is an invalid setting
  2355. // Returns False if all settings are valid
  2356. //
  2357. // SideEffect: displays error (or writes to log in silent mode)
  2358. BOOL VerifyPasswords(PSZ pszPassword, PSZ pszPasswordAgain, UINT min_pw_len)
  2359. {
  2360. BOOL bValueReturned = TRUE;
  2361. if (min_pw_len > strlen(pszPassword))
  2362. {
  2363. /* password failed minimum length check */
  2364. DSMessageBoxOK(ERR_PW_TOO_SHORT_TITLE, ERR_PW_TOO_SHORT, 0,
  2365. min_pw_len);
  2366. } else if ( contains8BitChars(pszPassword) )
  2367. {
  2368. /* check to make sure pw doesn't contain any 8bit chars */
  2369. DSMessageBoxOK(ERR_8BIT_PW_TITLE, ERR_8BIT_PW, 0);
  2370. } else if ( 0 == strlen(pszPasswordAgain) )
  2371. {
  2372. /* second password to verify missing */
  2373. DSMessageBoxOK(ERR_NO_PW_AGAIN_TITLE, ERR_NO_PW_AGAIN, 0);
  2374. } else if ( 0 != lstrcmp(pszPassword, pszPasswordAgain) )
  2375. {
  2376. /* passwords don't match */
  2377. DSMessageBoxOK(ERR_PW_DIFFER_TITLE, ERR_PW_DIFFER, 0);
  2378. }else{
  2379. /* passwords satisfied all checks so return false */
  2380. bValueReturned = FALSE;
  2381. }
  2382. return bValueReturned;
  2383. }
  2384. //////////////////////////////////////////////////////////////////////////////
  2385. // SaveDialogInput_RootDN
  2386. //
  2387. // saves input in root dn DialogProc
  2388. //
  2389. //
  2390. //
  2391. //
  2392. void SaveDialogInput_ROOTDN(HWND hwndDlg)
  2393. {
  2394. BOOL bValueReturned = FALSE;
  2395. UINT uResult = 0;
  2396. BOOL bResult = FALSE;
  2397. GetDlgItemText(hwndDlg,
  2398. IDC_EDIT_UNRESTRICTED_USER,
  2399. mi.m_szInstanceUnrestrictedUser,
  2400. MAX_STR_SIZE);
  2401. SaveDialogPasswords(hwndDlg,
  2402. mi.m_szInstancePassword,
  2403. mi.m_szInstancePasswordAgain);
  2404. }
  2405. //////////////////////////////////////////////////////////////////////////////
  2406. // Verify_RootDN
  2407. //
  2408. // verifies input in root dn DialogProc
  2409. //
  2410. //
  2411. // Returns TRUE if there is an invalid setting
  2412. // Returns FALSE if all settings are valid
  2413. //
  2414. // SideEffect: displays error (or writes to log in silent mode)
  2415. BOOL Verify_ROOTDN()
  2416. {
  2417. BOOL bValueReturned = FALSE;
  2418. if ( 0 == strlen(mi.m_szInstanceUnrestrictedUser) )
  2419. {
  2420. /* no value entered */
  2421. DSMessageBoxOK(ERR_NO_ROOT_DN_TITLE, ERR_NO_ROOT_DN, 0);
  2422. bValueReturned = TRUE;
  2423. }else if ( !isValidDN(mi.m_szInstanceUnrestrictedUser) )
  2424. {
  2425. /* error message displayed by isvalidDN */
  2426. bValueReturned = TRUE;
  2427. } else
  2428. {
  2429. /* only bother to check passwords if username is valid */
  2430. bValueReturned = VerifyPasswords(mi.m_szInstancePassword,
  2431. mi.m_szInstancePasswordAgain,
  2432. SLAPD_MIN_PW_LEN);
  2433. }
  2434. return bValueReturned;
  2435. }
  2436. //////////////////////////////////////////////////////////////////////////////
  2437. // RootDN_DialogProc
  2438. //
  2439. // dialog proc for the RootDN install page
  2440. //
  2441. //
  2442. //
  2443. //
  2444. static BOOL CALLBACK
  2445. RootDN_DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  2446. {
  2447. BOOL bValueReturned = FALSE;
  2448. UINT uResult = 0;
  2449. BOOL bResult = FALSE;
  2450. /* list of controls to be setup for 8bit input/display */
  2451. INT h8bitControls[]={IDC_EDIT_UNRESTRICTED_USER,
  2452. IDC_EDIT_PASSWORD,
  2453. IDC_EDIT_PASSWORD_AGAIN,
  2454. -1};
  2455. switch (uMsg)
  2456. {
  2457. case WM_INITDIALOG:
  2458. // This message is sent when the property page is first created. Here
  2459. // you can perform any one time initialization that you require.
  2460. Setup8bitInputDisplay(hwndDlg, h8bitControls);
  2461. break;
  2462. case WM_COMMAND:
  2463. // Windows sends WM_COMMAND messages whenever the user clicks on
  2464. // a control in your property page. If you need to perform some
  2465. // special action, such as validating data or responding to a
  2466. // button click, do it here.
  2467. break;
  2468. case WM_NOTIFY:
  2469. // Windows sends WM_NOTIFY messages to your property page whenever
  2470. // something interesting happens to the page. This could be page
  2471. // activation/deactivation, a button click, etc. The wParam parameter
  2472. // contains a pointer to the property page. The lParam parameter
  2473. // contains a pointer to an NMHDR structure. The code field of this
  2474. // structure contains the notification message code being sent. The
  2475. // property sheet API allows you to alter the behavior of these
  2476. // messages by returning a value for each message. To return a value,
  2477. // use the SetWindowLong Windows SDK function.
  2478. switch (((NMHDR*)lParam)->code)
  2479. {
  2480. case PSN_SETACTIVE:
  2481. // This notification is sent upon activation of the property page.
  2482. // The property sheet should be centered each time it is activated
  2483. // in case the user has moved the stupid thing (this duplicates
  2484. // InstallShield functionality). You should also set the state of
  2485. // the wizard buttons here.
  2486. //
  2487. // NOTE: If you do not wish this page to become active, return -1.
  2488. bResult = SetDlgItemText(hwndDlg,
  2489. IDC_EDIT_UNRESTRICTED_USER,
  2490. mi.m_szInstanceUnrestrictedUser);
  2491. if(FALSE == bResult)
  2492. {
  2493. DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
  2494. }
  2495. LoadDialogPasswords(hwndDlg,
  2496. mi.m_szInstancePassword,
  2497. mi.m_szInstancePasswordAgain);
  2498. CenterWindow(GetParent(hwndDlg));
  2499. PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
  2500. break;
  2501. case PSN_KILLACTIVE:
  2502. // This notification is sent upon deactivation of the property page.
  2503. // Here you can do whatever might be necessary for this action, such
  2504. // as saving the state of the controls. You should also reset the
  2505. // the state of the wizard buttons here, as both the Back and Next
  2506. // buttons should be active when you leave the AskOptions function.
  2507. //
  2508. // NOTE: If you do not want the page deactivated, return -1.
  2509. PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
  2510. break;
  2511. case PSN_WIZBACK:
  2512. // The user clicked the back button from the first property page.
  2513. // Set the result code NS_WIZBACK to indicate this action and close
  2514. // the property sheet using brute force. If this procedure is not
  2515. // being used by the first property sheet, you should ignore this
  2516. // notification and simply let windows go to the previous page.
  2517. //
  2518. // NOTE: To prevent the wizard from stepping back, return -1.
  2519. SaveDialogInput_ROOTDN(hwndDlg);
  2520. break;
  2521. case PSN_WIZNEXT:
  2522. // The user clicked the next button from the last property page.
  2523. // Set the result code NS_WIZNEXT to indicate this action and close
  2524. // the property sheet using brute force. If this procedure is not
  2525. // being used by the last property sheet, you should ignore this
  2526. // notification and simply let windows go to the next page.
  2527. //
  2528. // NOTE: To prevent the wizard from stepping ahead, return -1.
  2529. SaveDialogInput_ROOTDN(hwndDlg);
  2530. if ( FALSE == (bValueReturned = Verify_ROOTDN() ) )
  2531. {
  2532. /* all settings on this dialogue look good */
  2533. /* verify ldap settings */
  2534. if (0 != verify_ldap_settings() )
  2535. {
  2536. /* dont allow next until settings corrected */
  2537. SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
  2538. bValueReturned = TRUE;
  2539. } else
  2540. {
  2541. /* set ldap settings for other installs */
  2542. set_ldap_settings();
  2543. }
  2544. /* if not advanced mode move on to other installs */
  2545. if (CUSTOMMODE != MODE)
  2546. {
  2547. mi.m_nResult = NS_WIZNEXT;
  2548. SendMessage(GetParent(hwndDlg), WM_CLOSE, 0, 0);
  2549. }
  2550. } else
  2551. {
  2552. /* one of the settings was invalid, stay on this page */
  2553. SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
  2554. }
  2555. break;
  2556. case PSN_QUERYCANCEL:
  2557. // This notification is sent when the user clicks the Cancel button.
  2558. // It is also sent in response to the WM_CLOSE messages issued
  2559. // by PSN_WIZBACK and PSN_WIZNEXT. Make sure that we only process
  2560. // this message if the result is not back or next so that we don't
  2561. // nuke the return value assigned by PSN_WIZBACK or PSN_WIZNEXT.
  2562. //
  2563. // NOTE: To prevent the cancel from occuring, return -1.
  2564. if (mi.m_nResult != NS_WIZBACK && mi.m_nResult != NS_WIZNEXT)
  2565. {
  2566. if (QueryExit(hwndDlg))
  2567. {
  2568. mi.m_nResult = NS_WIZCANCEL;
  2569. }
  2570. else
  2571. {
  2572. SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
  2573. bValueReturned = TRUE;
  2574. }
  2575. }
  2576. break;
  2577. }
  2578. break;
  2579. }
  2580. return bValueReturned;
  2581. }
  2582. //////////////////////////////////////////////////////////////////////////////
  2583. //
  2584. // SaveDialogInput_SuitespotId
  2585. //
  2586. //
  2587. //
  2588. void SaveDialogInput_SuitespotId(HWND hwndDlg)
  2589. {
  2590. GetDlgItemText(hwndDlg,
  2591. IDC_EDIT_SUITESPOT_USER,
  2592. mi.m_szSsptUid,
  2593. MAX_STR_SIZE);
  2594. SaveDialogPasswords(hwndDlg,
  2595. mi.m_szSsptUidPw,
  2596. mi.m_szSsptUidPwAgain);
  2597. }
  2598. //////////////////////////////////////////////////////////////////////////////
  2599. //
  2600. // Verify_SuitespotId
  2601. //
  2602. // Returns TRUE if there is an invalid setting
  2603. // Returns FALSE if all settings are valid
  2604. //
  2605. // SideEffect: displays error (or writes to log in silent mode)
  2606. BOOL Verify_SuitespotId()
  2607. {
  2608. BOOL bValueReturned = FALSE;
  2609. if ( 0 == strlen(mi.m_szSsptUid) )
  2610. {
  2611. /* no value entered for sspt user */
  2612. DSMessageBoxOK(ERR_NO_SS_ADMIN_TITLE, ERR_NO_SS_ADMIN, 0);
  2613. bValueReturned = TRUE;
  2614. } else if (!isAValidDN(mi.m_szSsptUid) &&
  2615. contains8BitChars(mi.m_szSsptUid))
  2616. {
  2617. /* admin uid value not 7 bit */
  2618. DSMessageBoxOK(ERR_8BIT_UID_TITLE, ERR_8BIT_UID, 0);
  2619. bValueReturned = TRUE;
  2620. } else
  2621. {
  2622. /* only bother to check passwords if username is valid */
  2623. bValueReturned = VerifyPasswords(mi.m_szSsptUidPw,
  2624. mi.m_szSsptUidPwAgain,
  2625. SSPT_MIN_PW_LEN);
  2626. }
  2627. return bValueReturned;
  2628. }
  2629. //////////////////////////////////////////////////////////////////////////////
  2630. // SuitespotID_DialogProc
  2631. //
  2632. // dialog proc for the SUITESPOTID install page
  2633. //
  2634. //
  2635. //
  2636. //
  2637. static BOOL CALLBACK
  2638. SuitespotID_DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  2639. {
  2640. BOOL bValueReturned = FALSE;
  2641. UINT uResult = 0;
  2642. BOOL bResult = FALSE;
  2643. /* list of controls to be setup for 8bit input/display */
  2644. INT h8bitControls[]={IDC_EDIT_SUITESPOT_USER,
  2645. IDC_EDIT_PASSWORD,
  2646. IDC_EDIT_PASSWORD_AGAIN,
  2647. -1};
  2648. switch (uMsg)
  2649. {
  2650. case WM_INITDIALOG:
  2651. // This message is sent when the property page is first created. Here
  2652. // you can perform any one time initialization that you require.
  2653. Setup8bitInputDisplay(hwndDlg, h8bitControls);
  2654. break;
  2655. case WM_COMMAND:
  2656. // Windows sends WM_COMMAND messages whenever the user clicks on
  2657. // a control in your property page. If you need to perform some
  2658. // special action, such as validating data or responding to a
  2659. // button click, do it here.
  2660. break;
  2661. case WM_NOTIFY:
  2662. // Windows sends WM_NOTIFY messages to your property page whenever
  2663. // something interesting happens to the page. This could be page
  2664. // activation/deactivation, a button click, etc. The wParam parameter
  2665. // contains a pointer to the property page. The lParam parameter
  2666. // contains a pointer to an NMHDR structure. The code field of this
  2667. // structure contains the notification message code being sent. The
  2668. // property sheet API allows you to alter the behavior of these
  2669. // messages by returning a value for each message. To return a value,
  2670. // use the SetWindowLong Windows SDK function.
  2671. switch (((NMHDR*)lParam)->code)
  2672. {
  2673. case PSN_SETACTIVE:
  2674. // This notification is sent upon activation of the property page.
  2675. // The property sheet should be centered each time it is activated
  2676. // in case the user has moved the stupid thing (this duplicates
  2677. // InstallShield functionality). You should also set the state of
  2678. // the wizard buttons here.
  2679. //
  2680. // NOTE: If you do not wish this page to become active, return -1.
  2681. if(1 == mi.m_nExistingMCC)
  2682. {
  2683. /* don't display this dialog if using existing MCC since asked for it
  2684. there */
  2685. SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
  2686. return TRUE;
  2687. }
  2688. bResult = SetDlgItemText(hwndDlg,
  2689. IDC_EDIT_SUITESPOT_USER,
  2690. mi.m_szSsptUid);
  2691. if(FALSE == bResult)
  2692. {
  2693. DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
  2694. }
  2695. LoadDialogPasswords(hwndDlg,
  2696. mi.m_szSsptUidPw,
  2697. mi.m_szSsptUidPwAgain);
  2698. CenterWindow(GetParent(hwndDlg));
  2699. PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
  2700. break;
  2701. case PSN_KILLACTIVE:
  2702. // This notification is sent upon deactivation of the property page.
  2703. // Here you can do whatever might be necessary for this action, such
  2704. // as saving the state of the controls. You should also reset the
  2705. // the state of the wizard buttons here, as both the Back and Next
  2706. // buttons should be active when you leave the AskOptions function.
  2707. //
  2708. // NOTE: If you do not want the page deactivated, return -1.
  2709. PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
  2710. break;
  2711. case PSN_WIZBACK:
  2712. // The user clicked the back button from the first property page.
  2713. // Set the result code NS_WIZBACK to indicate this action and close
  2714. // the property sheet using brute force. If this procedure is not
  2715. // being used by the first property sheet, you should ignore this
  2716. // notification and simply let windows go to the previous page.
  2717. //
  2718. // NOTE: To prevent the wizard from stepping back, return -1.
  2719. SaveDialogInput_SuitespotId(hwndDlg);
  2720. // in express mode this is the first dialog, so set back to go to other module */
  2721. if (EXPRESSMODE == MODE)
  2722. {
  2723. mi.m_nResult = NS_WIZBACK;
  2724. SendMessage(GetParent(hwndDlg), WM_CLOSE, 0, 0);
  2725. }
  2726. break;
  2727. case PSN_WIZNEXT:
  2728. // The user clicked the next button from the last property page.
  2729. // Set the result code NS_WIZNEXT to indicate this action and close
  2730. // the property sheet using brute force. If this procedure is not
  2731. // being used by the last property sheet, you should ignore this
  2732. // notification and simply let windows go to the next page.
  2733. //
  2734. // NOTE: To prevent the wizard from stepping ahead, return -1.
  2735. SaveDialogInput_SuitespotId(hwndDlg);
  2736. if(TRUE == (bValueReturned = Verify_SuitespotId() ) )
  2737. {
  2738. /* one of the settings was invalid stay on this page */
  2739. SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
  2740. }
  2741. break;
  2742. case PSN_QUERYCANCEL:
  2743. // This notification is sent when the user clicks the Cancel button.
  2744. // It is also sent in response to the WM_CLOSE messages issued
  2745. // by PSN_WIZBACK and PSN_WIZNEXT. Make sure that we only process
  2746. // this message if the result is not back or next so that we don't
  2747. // nuke the return value assigned by PSN_WIZBACK or PSN_WIZNEXT.
  2748. //
  2749. // NOTE: To prevent the cancel from occuring, return -1.
  2750. if (mi.m_nResult != NS_WIZBACK && mi.m_nResult != NS_WIZNEXT)
  2751. {
  2752. if (QueryExit(hwndDlg))
  2753. {
  2754. mi.m_nResult = NS_WIZCANCEL;
  2755. }
  2756. else
  2757. {
  2758. SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
  2759. bValueReturned = TRUE;
  2760. }
  2761. }
  2762. break;
  2763. }
  2764. break;
  2765. }
  2766. return bValueReturned;
  2767. }
  2768. //////////////////////////////////////////////////////////////////////////////
  2769. // Admin_ID_Only_DialogProc
  2770. //
  2771. // dialog proc for the ADMIN_ID_ONLY install page
  2772. //
  2773. //
  2774. //
  2775. //
  2776. static BOOL CALLBACK
  2777. Admin_ID_Only_DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  2778. {
  2779. BOOL bValueReturned = FALSE;
  2780. UINT uResult = 0;
  2781. BOOL bResult = FALSE;
  2782. /* list of controls to be setup for 8bit input/display */
  2783. INT h8bitControls[]={IDC_EDIT_SUITESPOT_USER,
  2784. IDC_EDIT_PASSWORD,
  2785. -1};
  2786. switch (uMsg)
  2787. {
  2788. case WM_INITDIALOG:
  2789. // This message is sent when the property page is first created. Here
  2790. // you can perform any one time initialization that you require.
  2791. Setup8bitInputDisplay(hwndDlg, h8bitControls);
  2792. break;
  2793. case WM_COMMAND:
  2794. // Windows sends WM_COMMAND messages whenever the user clicks on
  2795. // a control in your property page. If you need to perform some
  2796. // special action, such as validating data or responding to a
  2797. // button click, do it here.
  2798. break;
  2799. case WM_NOTIFY:
  2800. // Windows sends WM_NOTIFY messages to your property page whenever
  2801. // something interesting happens to the page. This could be page
  2802. // activation/deactivation, a button click, etc. The wParam parameter
  2803. // contains a pointer to the property page. The lParam parameter
  2804. // contains a pointer to an NMHDR structure. The code field of this
  2805. // structure contains the notification message code being sent. The
  2806. // property sheet API allows you to alter the behavior of these
  2807. // messages by returning a value for each message. To return a value,
  2808. // use the SetWindowLong Windows SDK function.
  2809. switch (((NMHDR*)lParam)->code)
  2810. {
  2811. case PSN_SETACTIVE:
  2812. // This notification is sent upon activation of the property page.
  2813. // The property sheet should be centered each time it is activated
  2814. // in case the user has moved the stupid thing (this duplicates
  2815. // InstallShield functionality). You should also set the state of
  2816. // the wizard buttons here.
  2817. //
  2818. // NOTE: If you do not wish this page to become active, return -1.
  2819. bResult = SetDlgItemText(hwndDlg,
  2820. IDC_EDIT_SUITESPOT_USER,
  2821. mi.m_szMCCBindAs);
  2822. if(FALSE == bResult)
  2823. {
  2824. DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
  2825. }
  2826. LoadDialogPasswords(hwndDlg,
  2827. mi.m_szMCCPw,
  2828. 0);
  2829. CenterWindow(GetParent(hwndDlg));
  2830. PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
  2831. break;
  2832. case PSN_KILLACTIVE:
  2833. // This notification is sent upon deactivation of the property page.
  2834. // Here you can do whatever might be necessary for this action, such
  2835. // as saving the state of the controls. You should also reset the
  2836. // the state of the wizard buttons here, as both the Back and Next
  2837. // buttons should be active when you leave the AskOptions function.
  2838. //
  2839. // NOTE: If you do not want the page deactivated, return -1.
  2840. PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
  2841. break;
  2842. case PSN_WIZBACK:
  2843. // The user clicked the back button from the first property page.
  2844. // Set the result code NS_WIZBACK to indicate this action and close
  2845. // the property sheet using brute force. If this procedure is not
  2846. // being used by the first property sheet, you should ignore this
  2847. // notification and simply let windows go to the previous page.
  2848. //
  2849. // NOTE: To prevent the wizard from stepping back, return -1.
  2850. GetDlgItemText(hwndDlg,
  2851. IDC_EDIT_SUITESPOT_USER,
  2852. mi.m_szMCCBindAs,
  2853. MAX_STR_SIZE);
  2854. GetDlgItemText(hwndDlg,
  2855. IDC_EDIT_PASSWORD,
  2856. mi.m_szMCCPw,
  2857. MAX_STR_SIZE);
  2858. // in express mode this is the first dialog, so set back to go to other module */
  2859. if (EXPRESSMODE == MODE)
  2860. {
  2861. mi.m_nResult = NS_WIZBACK;
  2862. SendMessage(GetParent(hwndDlg), WM_CLOSE, 0, 0);
  2863. }
  2864. break;
  2865. case PSN_WIZNEXT:
  2866. // The user clicked the next button from the last property page.
  2867. // Set the result code NS_WIZNEXT to indicate this action and close
  2868. // the property sheet using brute force. If this procedure is not
  2869. // being used by the last property sheet, you should ignore this
  2870. // notification and simply let windows go to the next page.
  2871. //
  2872. // NOTE: To prevent the wizard from stepping ahead, return -1.
  2873. GetDlgItemText(hwndDlg,
  2874. IDC_EDIT_SUITESPOT_USER,
  2875. mi.m_szMCCBindAs,
  2876. MAX_STR_SIZE);
  2877. GetDlgItemText(hwndDlg,
  2878. IDC_EDIT_PASSWORD,
  2879. mi.m_szMCCPw,
  2880. MAX_STR_SIZE);
  2881. if(TRUE == (bValueReturned = Verify_MCC_Settings() ) )
  2882. {
  2883. /* one of the settings was invalid stay on this page */
  2884. SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
  2885. }
  2886. break;
  2887. case PSN_QUERYCANCEL:
  2888. // This notification is sent when the user clicks the Cancel button.
  2889. // It is also sent in response to the WM_CLOSE messages issued
  2890. // by PSN_WIZBACK and PSN_WIZNEXT. Make sure that we only process
  2891. // this message if the result is not back or next so that we don't
  2892. // nuke the return value assigned by PSN_WIZBACK or PSN_WIZNEXT.
  2893. //
  2894. // NOTE: To prevent the cancel from occuring, return -1.
  2895. if (mi.m_nResult != NS_WIZBACK && mi.m_nResult != NS_WIZNEXT)
  2896. {
  2897. if (QueryExit(hwndDlg))
  2898. {
  2899. mi.m_nResult = NS_WIZCANCEL;
  2900. }
  2901. else
  2902. {
  2903. SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
  2904. bValueReturned = TRUE;
  2905. }
  2906. }
  2907. break;
  2908. }
  2909. break;
  2910. }
  2911. return bValueReturned;
  2912. }
  2913. //////////////////////////////////////////////////////////////////////////////
  2914. // Choose_Replication_DialogProc
  2915. //
  2916. // choose the type of replicatin to do, determine which pages to ask next
  2917. //
  2918. //
  2919. //
  2920. //
  2921. static BOOL CALLBACK
  2922. Choose_Replication_DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  2923. {
  2924. BOOL bValueReturned = FALSE;
  2925. UINT uResult = 0;
  2926. BOOL bResult = FALSE;
  2927. switch (uMsg)
  2928. {
  2929. case WM_INITDIALOG:
  2930. // This message is sent when the property page is first created. Here
  2931. // you can perform any one time initialization that you require.
  2932. break;
  2933. case WM_COMMAND:
  2934. // Windows sends WM_COMMAND messages whenever the user clicks on
  2935. // a control in your property page. If you need to perform some
  2936. // special action, such as validating data or responding to a
  2937. // button click, do it here.
  2938. /* consumer replication */
  2939. if(BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_RADIO_NO_CONSUMER_REPLICATION ) )
  2940. {
  2941. mi.m_nSetupConsumerReplication = NO_REPLICATION;
  2942. }else if(BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_RADIO_CONSUMER_CIR ) ){
  2943. mi.m_nSetupConsumerReplication = CONSUMER_CIR_REPLICATION;
  2944. }else if(BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_RADIO_CONSUMER_SIR ) ){
  2945. mi.m_nSetupConsumerReplication = CONSUMER_SIR_REPLICATION;
  2946. }
  2947. /* supplier replication */
  2948. if( BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_RADIO_NO_SUPPLIER_REPLICATION ) )
  2949. {
  2950. mi.m_nSetupSupplierReplication = NO_REPLICATION;
  2951. }else if(BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_RADIO_SUPPLIER_CIR ) ){
  2952. mi.m_nSetupSupplierReplication = SUPPLIER_CIR_REPLICATION;
  2953. }else if(BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_RADIO_SUPPLIER_SIR ) ){
  2954. mi.m_nSetupSupplierReplication = SUPPLIER_SIR_REPLICATION;
  2955. }
  2956. break;
  2957. case WM_NOTIFY:
  2958. // Windows sends WM_NOTIFY messages to your property page whenever
  2959. // something interesting happens to the page. This could be page
  2960. // activation/deactivation, a button click, etc. The wParam parameter
  2961. // contains a pointer to the property page. The lParam parameter
  2962. // contains a pointer to an NMHDR structure. The code field of this
  2963. // structure contains the notification message code being sent. The
  2964. // property sheet API allows you to alter the behavior of these
  2965. // messages by returning a value for each message. To return a value,
  2966. // use the SetWindowLong Windows SDK function.
  2967. switch (((NMHDR*)lParam)->code)
  2968. {
  2969. case PSN_SETACTIVE:
  2970. // This notification is sent upon activation of the property page.
  2971. // The property sheet should be centered each time it is activated
  2972. // in case the user has moved the stupid thing (this duplicates
  2973. // InstallShield functionality). You should also set the state of
  2974. // the wizard buttons here.
  2975. //
  2976. // NOTE: If you do not wish this page to become active, return -1.
  2977. /* set buttons for appropriate replication type */
  2978. if(CONSUMER_CIR_REPLICATION == mi.m_nSetupConsumerReplication)
  2979. {
  2980. CheckDlgButton(hwndDlg, IDC_RADIO_CONSUMER_CIR, BST_CHECKED);
  2981. }else if(CONSUMER_SIR_REPLICATION == mi.m_nSetupConsumerReplication){
  2982. CheckDlgButton(hwndDlg, IDC_RADIO_CONSUMER_SIR, BST_CHECKED);
  2983. }else{
  2984. CheckDlgButton(hwndDlg, IDC_RADIO_NO_CONSUMER_REPLICATION, BST_CHECKED);
  2985. }
  2986. if(SUPPLIER_CIR_REPLICATION == mi.m_nSetupSupplierReplication)
  2987. {
  2988. CheckDlgButton(hwndDlg, IDC_RADIO_SUPPLIER_CIR, BST_CHECKED);
  2989. }else if(SUPPLIER_SIR_REPLICATION == mi.m_nSetupSupplierReplication){
  2990. CheckDlgButton(hwndDlg, IDC_RADIO_SUPPLIER_SIR, BST_CHECKED);
  2991. }else{
  2992. CheckDlgButton(hwndDlg, IDC_RADIO_NO_SUPPLIER_REPLICATION, BST_CHECKED);
  2993. }
  2994. CenterWindow(GetParent(hwndDlg));
  2995. PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
  2996. break;
  2997. case PSN_KILLACTIVE:
  2998. // This notification is sent upon deactivation of the property page.
  2999. // Here you can do whatever might be necessary for this action, such
  3000. // as saving the state of the controls. You should also reset the
  3001. // the state of the wizard buttons here, as both the Back and Next
  3002. // buttons should be active when you leave the AskOptions function.
  3003. //
  3004. // NOTE: If you do not want the page deactivated, return -1.
  3005. PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
  3006. break;
  3007. case PSN_WIZBACK:
  3008. // The user clicked the back button from the first property page.
  3009. // Set the result code NS_WIZBACK to indicate this action and close
  3010. // the property sheet using brute force. If this procedure is not
  3011. // being used by the first property sheet, you should ignore this
  3012. // notification and simply let windows go to the previous page.
  3013. //
  3014. // NOTE: To prevent the wizard from stepping back, return -1.
  3015. // simple dialog, all button state gets saved in WM_COMMAND proccessing
  3016. break;
  3017. case PSN_WIZNEXT:
  3018. // The user clicked the next button from the last property page.
  3019. // Set the result code NS_WIZNEXT to indicate this action and close
  3020. // the property sheet using brute force. If this procedure is not
  3021. // being used by the last property sheet, you should ignore this
  3022. // notification and simply let windows go to the next page.
  3023. //
  3024. // NOTE: To prevent the wizard from stepping ahead, return -1.
  3025. // simple dialog, all button state gets saved in WM_COMMAND proccessing
  3026. break;
  3027. case PSN_QUERYCANCEL:
  3028. // This notification is sent when the user clicks the Cancel button.
  3029. // It is also sent in response to the WM_CLOSE messages issued
  3030. // by PSN_WIZBACK and PSN_WIZNEXT. Make sure that we only process
  3031. // this message if the result is not back or next so that we don't
  3032. // nuke the return value assigned by PSN_WIZBACK or PSN_WIZNEXT.
  3033. //
  3034. // NOTE: To prevent the cancel from occuring, return -1.
  3035. if (mi.m_nResult != NS_WIZBACK && mi.m_nResult != NS_WIZNEXT)
  3036. {
  3037. if (QueryExit(hwndDlg))
  3038. {
  3039. mi.m_nResult = NS_WIZCANCEL;
  3040. }
  3041. else
  3042. {
  3043. SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
  3044. bValueReturned = TRUE;
  3045. }
  3046. }
  3047. break;
  3048. }
  3049. break;
  3050. }
  3051. return bValueReturned;
  3052. }
  3053. //////////////////////////////////////////////////////////////////////////////
  3054. // SaveDialogInput_Consumer_Replication
  3055. //
  3056. // save settings from ConsumerReplication Dialog
  3057. //
  3058. //
  3059. //
  3060. //
  3061. void SaveDialogInput_Consumer_Replication(HWND hwndDlg)
  3062. {
  3063. if ( CONSUMER_SIR_REPLICATION == mi.m_nSetupConsumerReplication )
  3064. {
  3065. GetDlgItemText(hwndDlg,
  3066. IDC_EDIT_SUPPLIER_DN,
  3067. mi.m_szSupplierDN,
  3068. MAX_STR_SIZE);
  3069. SaveDialogPasswords(hwndDlg,
  3070. mi.m_szSupplierPW,
  3071. mi.m_szSupplierPWAgain);
  3072. }
  3073. }
  3074. //////////////////////////////////////////////////////////////////////////////
  3075. // Verify_Consumer_Replication
  3076. //
  3077. // save settings from ConsumerReplication Dialog
  3078. //
  3079. //
  3080. // Returns TRUE if there is an invalid setting
  3081. // Returns FALSE if all settings are valid
  3082. //
  3083. // SideEffect: displays error (or writes to log in silent mode)
  3084. BOOL Verify_Consumer_Replication()
  3085. {
  3086. BOOL bValueReturned = FALSE;
  3087. /* only check if configuring consumer replication */
  3088. if ( CONSUMER_SIR_REPLICATION == mi.m_nSetupConsumerReplication )
  3089. {
  3090. if ( 0 == strlen(mi.m_szSupplierDN) )
  3091. {
  3092. /* no value entered for Supplier DN */
  3093. DSMessageBoxOK(ERR_NO_SUPPLIER_DN_TITLE,
  3094. ERR_NO_SUPPLIER_DN, 0);
  3095. bValueReturned = TRUE;
  3096. }else if ( !isValidDN(mi.m_szSupplierDN) )
  3097. {
  3098. /* error message displayed by isvalidDN */
  3099. bValueReturned = TRUE;
  3100. } else
  3101. {
  3102. bValueReturned = VerifyPasswords(mi.m_szSupplierPW,
  3103. mi.m_szSupplierPWAgain,
  3104. SLAPD_MIN_PW_LEN);
  3105. }
  3106. }
  3107. return bValueReturned;
  3108. }
  3109. //////////////////////////////////////////////////////////////////////////////
  3110. // Consumer_Replication_DialogProc
  3111. //
  3112. // ask common settings needed for this server to be a consumer
  3113. //
  3114. //
  3115. //
  3116. //
  3117. static BOOL CALLBACK
  3118. Consumer_Replication_DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  3119. {
  3120. BOOL bValueReturned = FALSE;
  3121. UINT uResult = 0;
  3122. BOOL bResult = FALSE;
  3123. /* list of controls to be setup for 8bit input/display */
  3124. INT h8bitControls[]={IDC_EDIT_SUPPLIER_DN,
  3125. IDC_EDIT_PASSWORD,
  3126. IDC_EDIT_PASSWORD_AGAIN,
  3127. -1};
  3128. switch (uMsg)
  3129. {
  3130. case WM_INITDIALOG:
  3131. // This message is sent when the property page is first created. Here
  3132. // you can perform any one time initialization that you require.
  3133. Setup8bitInputDisplay(hwndDlg, h8bitControls);
  3134. break;
  3135. case WM_COMMAND:
  3136. // Windows sends WM_COMMAND messages whenever the user clicks on
  3137. // a control in your property page. If you need to perform some
  3138. // special action, such as validating data or responding to a
  3139. // button click, do it here.
  3140. break;
  3141. case WM_NOTIFY:
  3142. // Windows sends WM_NOTIFY messages to your property page whenever
  3143. // something interesting happens to the page. This could be page
  3144. // activation/deactivation, a button click, etc. The wParam parameter
  3145. // contains a pointer to the property page. The lParam parameter
  3146. // contains a pointer to an NMHDR structure. The code field of this
  3147. // structure contains the notification message code being sent. The
  3148. // property sheet API allows you to alter the behavior of these
  3149. // messages by returning a value for each message. To return a value,
  3150. // use the SetWindowLong Windows SDK function.
  3151. switch (((NMHDR*)lParam)->code)
  3152. {
  3153. case PSN_SETACTIVE:
  3154. // This notification is sent upon activation of the property page.
  3155. // The property sheet should be centered each time it is activated
  3156. // in case the user has moved the stupid thing (this duplicates
  3157. // InstallShield functionality). You should also set the state of
  3158. // the wizard buttons here.
  3159. //
  3160. // NOTE: If you do not wish this page to become active, return -1.
  3161. if( CONSUMER_SIR_REPLICATION != mi.m_nSetupConsumerReplication )
  3162. {
  3163. /* we only want this dialog for Consumer SIR replication */
  3164. SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
  3165. return TRUE;
  3166. }
  3167. bResult = SetDlgItemText(hwndDlg,
  3168. IDC_EDIT_SUPPLIER_DN,
  3169. mi.m_szSupplierDN);
  3170. if(FALSE == bResult)
  3171. {
  3172. DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
  3173. }
  3174. LoadDialogPasswords(hwndDlg,
  3175. mi.m_szSupplierPW,
  3176. mi.m_szSupplierPWAgain);
  3177. CenterWindow(GetParent(hwndDlg));
  3178. PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
  3179. break;
  3180. case PSN_KILLACTIVE:
  3181. // This notification is sent upon deactivation of the property page.
  3182. // Here you can do whatever might be necessary for this action, such
  3183. // as saving the state of the controls. You should also reset the
  3184. // the state of the wizard buttons here, as both the Back and Next
  3185. // buttons should be active when you leave the AskOptions function.
  3186. //
  3187. // NOTE: If you do not want the page deactivated, return -1.
  3188. PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
  3189. break;
  3190. case PSN_WIZBACK:
  3191. // The user clicked the back button from the first property page.
  3192. // Set the result code NS_WIZBACK to indicate this action and close
  3193. // the property sheet using brute force. If this procedure is not
  3194. // being used by the first property sheet, you should ignore this
  3195. // notification and simply let windows go to the previous page.
  3196. //
  3197. // NOTE: To prevent the wizard from stepping back, return -1.
  3198. SaveDialogInput_Consumer_Replication(hwndDlg);
  3199. break;
  3200. case PSN_WIZNEXT:
  3201. // The user clicked the next button from the last property page.
  3202. // Set the result code NS_WIZNEXT to indicate this action and close
  3203. // the property sheet using brute force. If this procedure is not
  3204. // being used by the last property sheet, you should ignore this
  3205. // notification and simply let windows go to the next page.
  3206. //
  3207. // NOTE: To prevent the wizard from stepping ahead, return -1.
  3208. SaveDialogInput_Consumer_Replication(hwndDlg);
  3209. if( TRUE == (bValueReturned = Verify_Consumer_Replication() ) )
  3210. {
  3211. /* a setting was invalid stay on this page*/
  3212. SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
  3213. }else{
  3214. /* all settings on this dialogue look good */
  3215. /* these settings were specified, ok to use them */
  3216. mi.m_nUseSupplierSettings = 1;
  3217. }
  3218. break;
  3219. case PSN_QUERYCANCEL:
  3220. // This notification is sent when the user clicks the Cancel button.
  3221. // It is also sent in response to the WM_CLOSE messages issued
  3222. // by PSN_WIZBACK and PSN_WIZNEXT. Make sure that we only process
  3223. // this message if the result is not back or next so that we don't
  3224. // nuke the return value assigned by PSN_WIZBACK or PSN_WIZNEXT.
  3225. //
  3226. // NOTE: To prevent the cancel from occuring, return -1.
  3227. if (mi.m_nResult != NS_WIZBACK && mi.m_nResult != NS_WIZNEXT)
  3228. {
  3229. if (QueryExit(hwndDlg))
  3230. {
  3231. mi.m_nResult = NS_WIZCANCEL;
  3232. }
  3233. else
  3234. {
  3235. SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
  3236. bValueReturned = TRUE;
  3237. }
  3238. }
  3239. break;
  3240. }
  3241. break;
  3242. }
  3243. return bValueReturned;
  3244. }
  3245. //////////////////////////////////////////////////////////////////////////////
  3246. // SaveDialogInput_Supplier_Replication
  3247. //
  3248. // save supplier settings
  3249. //
  3250. //
  3251. //
  3252. //
  3253. void SaveDialogInput_Supplier_Replication(HWND hwndDlg)
  3254. {
  3255. GetDlgItemText(hwndDlg,
  3256. IDC_EDIT_CHANGELOG_DB_DIR,
  3257. mi.m_szChangeLogDbDir,
  3258. MAX_STR_SIZE);
  3259. GetDlgItemText(hwndDlg,
  3260. IDC_EDIT_CHANGELOG_DB_SUFFIX,
  3261. mi.m_szChangeLogSuffix,
  3262. MAX_STR_SIZE);
  3263. }
  3264. //////////////////////////////////////////////////////////////////////////////
  3265. // Verify_Supplier_Replication
  3266. //
  3267. // save supplier settings
  3268. //
  3269. //
  3270. // Returns TRUE if there is an invalid setting
  3271. // Returns FALSE if all settings are valid
  3272. //
  3273. // SideEffect: displays error (or writes to log in silent mode)
  3274. BOOL Verify_Supplier_Replication()
  3275. {
  3276. BOOL bValueReturned = TRUE;
  3277. if ( 0 == strlen(mi.m_szChangeLogDbDir) )
  3278. {
  3279. DSMessageBoxOK(ERR_NO_CHANGELOG_DB_TITLE,
  3280. ERR_NO_CHANGELOG_DB, 0);
  3281. } else if ( contains8BitChars(mi.m_szChangeLogDbDir) )
  3282. {
  3283. /* make sure the path doesnt contain international characters */
  3284. DSMessageBoxOK(ERR_8BIT_PATH_TITLE, ERR_8BIT_PATH, 0);
  3285. } else if ( 0 == strlen(mi.m_szChangeLogSuffix) )
  3286. {
  3287. DSMessageBoxOK(ERR_NO_CHANGELOG_SUFFIX_TITLE,
  3288. ERR_NO_CHANGELOG_SUFFIX, 0);
  3289. } else if ( !isValidDN(mi.m_szChangeLogSuffix) )
  3290. {
  3291. /* error message displayed by isValidDN */
  3292. }else{
  3293. /* all settings lookg good */
  3294. bValueReturned = FALSE;
  3295. }
  3296. return bValueReturned;
  3297. }
  3298. //////////////////////////////////////////////////////////////////////////////
  3299. // Supplier_Replication_DialogProc
  3300. //
  3301. // ask common settings for this server to be a suppplier
  3302. //
  3303. //
  3304. //
  3305. //
  3306. static BOOL CALLBACK
  3307. Supplier_Replication_DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  3308. {
  3309. BOOL bValueReturned = FALSE;
  3310. UINT uResult = 0;
  3311. BOOL bResult = FALSE;
  3312. static INT nInitialized = 0;
  3313. /* list of controls to be setup for 8bit input/display */
  3314. INT h8bitControls[]={IDC_EDIT_CHANGELOG_DB_DIR,
  3315. IDC_EDIT_CHANGELOG_DB_SUFFIX,
  3316. -1};
  3317. switch (uMsg)
  3318. {
  3319. case WM_INITDIALOG:
  3320. // This message is sent when the property page is first created. Here
  3321. // you can perform any one time initialization that you require.
  3322. Setup8bitInputDisplay(hwndDlg, h8bitControls);
  3323. // need to initialize the changelog dir the first time
  3324. // this dialog is created. This is because
  3325. // the default values are set on dllMain and it wouldn't
  3326. // pick up the users change of target dir to calculate it
  3327. // reason for nInitialized is so it doesn't blow away
  3328. // users changes after leaving module and window is recreated
  3329. // and wm_init is called again
  3330. if( !nInitialized )
  3331. {
  3332. my_snprintf(mi.m_szChangeLogDbDir, sizeof(mi.m_szChangeLogDbDir),"%s\\%s-%s\\%s", TARGETDIR,
  3333. DS_ID_SERVICE, mi.m_szServerIdentifier, DEFAULT_CHANGELOGDIR);
  3334. nInitialized = 1;
  3335. }
  3336. break;
  3337. case WM_COMMAND:
  3338. // Windows sends WM_COMMAND messages whenever the user clicks on
  3339. // a control in your property page. If you need to perform some
  3340. // special action, such as validating data or responding to a
  3341. // button click, do it here.
  3342. break;
  3343. case WM_NOTIFY:
  3344. // Windows sends WM_NOTIFY messages to your property page whenever
  3345. // something interesting happens to the page. This could be page
  3346. // activation/deactivation, a button click, etc. The wParam parameter
  3347. // contains a pointer to the property page. The lParam parameter
  3348. // contains a pointer to an NMHDR structure. The code field of this
  3349. // structure contains the notification message code being sent. The
  3350. // property sheet API allows you to alter the behavior of these
  3351. // messages by returning a value for each message. To return a value,
  3352. // use the SetWindowLong Windows SDK function.
  3353. switch (((NMHDR*)lParam)->code)
  3354. {
  3355. case PSN_SETACTIVE:
  3356. // This notification is sent upon activation of the property page.
  3357. // The property sheet should be centered each time it is activated
  3358. // in case the user has moved the stupid thing (this duplicates
  3359. // InstallShield functionality). You should also set the state of
  3360. // the wizard buttons here.
  3361. //
  3362. // NOTE: If you do not wish this page to become active, return -1.
  3363. if( NO_REPLICATION == mi.m_nSetupSupplierReplication)
  3364. {
  3365. /* we dont want to display this page unless this server is a supplier*/
  3366. SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
  3367. return TRUE;
  3368. }
  3369. bResult = SetDlgItemText(hwndDlg,
  3370. IDC_EDIT_CHANGELOG_DB_SUFFIX,
  3371. mi.m_szChangeLogSuffix);
  3372. if(FALSE == bResult)
  3373. {
  3374. DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
  3375. }
  3376. bResult = SetDlgItemText(hwndDlg,
  3377. IDC_EDIT_CHANGELOG_DB_DIR,
  3378. mi.m_szChangeLogDbDir);
  3379. if(FALSE == bResult)
  3380. {
  3381. DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
  3382. }
  3383. CenterWindow(GetParent(hwndDlg));
  3384. PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
  3385. break;
  3386. case PSN_KILLACTIVE:
  3387. // This notification is sent upon deactivation of the property page.
  3388. // Here you can do whatever might be necessary for this action, such
  3389. // as saving the state of the controls. You should also reset the
  3390. // the state of the wizard buttons here, as both the Back and Next
  3391. // buttons should be active when you leave the AskOptions function.
  3392. //
  3393. // NOTE: If you do not want the page deactivated, return -1.
  3394. PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
  3395. break;
  3396. case PSN_WIZBACK:
  3397. // The user clicked the back button from the first property page.
  3398. // Set the result code NS_WIZBACK to indicate this action and close
  3399. // the property sheet using brute force. If this procedure is not
  3400. // being used by the first property sheet, you should ignore this
  3401. // notification and simply let windows go to the previous page.
  3402. //
  3403. // NOTE: To prevent the wizard from stepping back, return -1.
  3404. SaveDialogInput_Supplier_Replication(hwndDlg);
  3405. break;
  3406. case PSN_WIZNEXT:
  3407. // The user clicked the next button from the last property page.
  3408. // Set the result code NS_WIZNEXT to indicate this action and close
  3409. // the property sheet using brute force. If this procedure is not
  3410. // being used by the last property sheet, you should ignore this
  3411. // notification and simply let windows go to the next page.
  3412. //
  3413. // NOTE: To prevent the wizard from stepping ahead, return -1.
  3414. SaveDialogInput_Supplier_Replication(hwndDlg);
  3415. if ( FALSE == (bValueReturned = Verify_Supplier_Replication() ) )
  3416. {
  3417. /* all settings look good */
  3418. /* user chose these settings through dialog so use them */
  3419. mi.m_nUseChangeLogSettings = 1;
  3420. }else{
  3421. /* one of the settings is invalid, stay on this page */
  3422. SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
  3423. }
  3424. break;
  3425. case PSN_QUERYCANCEL:
  3426. // This notification is sent when the user clicks the Cancel button.
  3427. // It is also sent in response to the WM_CLOSE messages issued
  3428. // by PSN_WIZBACK and PSN_WIZNEXT. Make sure that we only process
  3429. // this message if the result is not back or next so that we don't
  3430. // nuke the return value assigned by PSN_WIZBACK or PSN_WIZNEXT.
  3431. //
  3432. // NOTE: To prevent the cancel from occuring, return -1.
  3433. if (mi.m_nResult != NS_WIZBACK && mi.m_nResult != NS_WIZNEXT)
  3434. {
  3435. if (QueryExit(hwndDlg))
  3436. {
  3437. mi.m_nResult = NS_WIZCANCEL;
  3438. }
  3439. else
  3440. {
  3441. SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
  3442. bValueReturned = TRUE;
  3443. }
  3444. }
  3445. break;
  3446. }
  3447. break;
  3448. }
  3449. return bValueReturned;
  3450. }
  3451. //////////////////////////////////////////////////////////////////////////////
  3452. // SaveDialogInput_Consumer_DN
  3453. //
  3454. //
  3455. // save input for Consumer DN dialog
  3456. //
  3457. //
  3458. void SaveDialogInput_Consumer_DN(HWND hwndDlg)
  3459. {
  3460. if (1 == mi.m_nConfigConsumerDN)
  3461. {
  3462. GetDlgItemText(hwndDlg,
  3463. IDC_EDIT_CONSUMER_DN,
  3464. mi.m_szConsumerDN,
  3465. MAX_STR_SIZE);
  3466. SaveDialogPasswords(hwndDlg,
  3467. mi.m_szConsumerPW,
  3468. mi.m_szConsumerPWAgain);
  3469. }
  3470. }
  3471. //////////////////////////////////////////////////////////////////////////////
  3472. // Verify_Consumer_DN
  3473. //
  3474. //
  3475. // verify input for Consumer DN dialog
  3476. //
  3477. // Returns TRUE if there is an invalid setting
  3478. // Returns FALSE if all settings are valid
  3479. //
  3480. // SideEffect: displays error (or writes to log in silent mode)
  3481. BOOL Verify_Consumer_DN()
  3482. {
  3483. BOOL bValueReturned = FALSE;
  3484. /* only verify if trying to use these settings */
  3485. if (1 == mi.m_nConfigConsumerDN)
  3486. {
  3487. if ( 0 == strlen(mi.m_szConsumerDN) )
  3488. {
  3489. /* no value entered for consumer dn */
  3490. DSMessageBoxOK(ERR_NO_CONSUMER_DN_TITLE, ERR_NO_CONSUMER_DN, 0);
  3491. bValueReturned = TRUE;
  3492. }else if ( !isValidDN(mi.m_szConsumerDN) )
  3493. {
  3494. /* error message displayed by isvalidDN */
  3495. bValueReturned = TRUE;
  3496. } else
  3497. {
  3498. /* only bother to check passwords if username is valid */
  3499. bValueReturned = VerifyPasswords(mi.m_szConsumerPW,
  3500. mi.m_szConsumerPWAgain,
  3501. SLAPD_MIN_PW_LEN);
  3502. }
  3503. }
  3504. return bValueReturned;
  3505. }
  3506. //////////////////////////////////////////////////////////////////////////////
  3507. // Consumer_DN_DialogProc
  3508. //
  3509. // dialog proc for the Consumer DN page
  3510. // displayed only under Supplier CIR replication
  3511. //
  3512. //
  3513. static BOOL CALLBACK
  3514. Consumer_DN_DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  3515. {
  3516. BOOL bValueReturned = FALSE;
  3517. UINT uResult = 0;
  3518. BOOL bResult = FALSE;
  3519. /* list of controls to be setup for 8bit input/display */
  3520. INT h8bitControls[]={IDC_EDIT_CONSUMER_DN,
  3521. IDC_EDIT_PASSWORD,
  3522. IDC_EDIT_PASSWORD_AGAIN,
  3523. -1};
  3524. switch (uMsg)
  3525. {
  3526. case WM_INITDIALOG:
  3527. // This message is sent when the property page is first created. Here
  3528. // you can perform any one time initialization that you require.
  3529. Setup8bitInputDisplay(hwndDlg, h8bitControls);
  3530. my_snprintf(mi.m_szConsumerDN, sizeof(mi.m_szConsumerDN), "%s,%s", DEFAULT_CONSUMER_DN, mi.m_szInstanceSuffix);
  3531. break;
  3532. case WM_COMMAND:
  3533. // Windows sends WM_COMMAND messages whenever the user clicks on
  3534. // a control in your property page. If you need to perform some
  3535. // special action, such as validating data or responding to a
  3536. // button click, do it here.
  3537. if(BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_RADIO_CONFIG_CONSUMER_DN_YES) )
  3538. {
  3539. EnableConsumerDNFields(hwndDlg, TRUE);
  3540. mi.m_nConfigConsumerDN = 1;
  3541. }else if(BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_RADIO_CONFIG_CONSUMER_DN_NO) ){
  3542. EnableConsumerDNFields(hwndDlg, FALSE);
  3543. mi.m_nConfigConsumerDN = 0;
  3544. }
  3545. break;
  3546. case WM_NOTIFY:
  3547. // Windows sends WM_NOTIFY messages to your property page whenever
  3548. // something interesting happens to the page. This could be page
  3549. // activation/deactivation, a button click, etc. The wParam parameter
  3550. // contains a pointer to the property page. The lParam parameter
  3551. // contains a pointer to an NMHDR structure. The code field of this
  3552. // structure contains the notification message code being sent. The
  3553. // property sheet API allows you to alter the behavior of these
  3554. // messages by returning a value for each message. To return a value,
  3555. // use the SetWindowLong Windows SDK function.
  3556. switch (((NMHDR*)lParam)->code)
  3557. {
  3558. case PSN_SETACTIVE:
  3559. // This notification is sent upon activation of the property page.
  3560. // The property sheet should be centered each time it is activated
  3561. // in case the user has moved the stupid thing (this duplicates
  3562. // InstallShield functionality). You should also set the state of
  3563. // the wizard buttons here.
  3564. //
  3565. // NOTE: If you do not wish this page to become active, return -1.
  3566. if( SUPPLIER_CIR_REPLICATION != mi.m_nSetupSupplierReplication )
  3567. {
  3568. /* we only ask consumer dn for supplier cir*/
  3569. SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
  3570. return TRUE;
  3571. }
  3572. bResult = SetDlgItemText(hwndDlg,
  3573. IDC_EDIT_CONSUMER_DN,
  3574. mi.m_szConsumerDN);
  3575. if(FALSE == bResult)
  3576. {
  3577. DSMessageBoxOK(ERR_INIT_DIALOG_TITLE, ERR_INIT_DIALOG, 0);
  3578. }
  3579. LoadDialogPasswords(hwndDlg,
  3580. mi.m_szConsumerPW,
  3581. mi.m_szConsumerPWAgain);
  3582. CheckRadioButton(hwndDlg, IDC_RADIO_CONFIG_CONSUMER_DN_YES, IDC_RADIO_CONFIG_CONSUMER_DN_NO,
  3583. ( (1 == mi.m_nConfigConsumerDN) ? IDC_RADIO_CONFIG_CONSUMER_DN_YES :
  3584. IDC_RADIO_CONFIG_CONSUMER_DN_NO));
  3585. if(1 == mi.m_nConfigConsumerDN)
  3586. {
  3587. EnableConsumerDNFields(hwndDlg, TRUE);
  3588. }else{
  3589. EnableConsumerDNFields(hwndDlg, FALSE);
  3590. }
  3591. CenterWindow(GetParent(hwndDlg));
  3592. PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
  3593. break;
  3594. case PSN_KILLACTIVE:
  3595. // This notification is sent upon deactivation of the property page.
  3596. // Here you can do whatever might be necessary for this action, such
  3597. // as saving the state of the controls. You should also reset the
  3598. // the state of the wizard buttons here, as both the Back and Next
  3599. // buttons should be active when you leave the AskOptions function.
  3600. //
  3601. // NOTE: If you do not want the page deactivated, return -1.
  3602. PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
  3603. break;
  3604. case PSN_WIZBACK:
  3605. // The user clicked the back button from the first property page.
  3606. // Set the result code NS_WIZBACK to indicate this action and close
  3607. // the property sheet using brute force. If this procedure is not
  3608. // being used by the first property sheet, you should ignore this
  3609. // notification and simply let windows go to the previous page.
  3610. //
  3611. // NOTE: To prevent the wizard from stepping back, return -1.
  3612. SaveDialogInput_Consumer_DN(hwndDlg);
  3613. break;
  3614. case PSN_WIZNEXT:
  3615. // The user clicked the next button from the last property page.
  3616. // Set the result code NS_WIZNEXT to indicate this action and close
  3617. // the property sheet using brute force. If this procedure is not
  3618. // being used by the last property sheet, you should ignore this
  3619. // notification and simply let windows go to the next page.
  3620. //
  3621. // NOTE: To prevent the wizard from stepping ahead, return -1.
  3622. SaveDialogInput_Consumer_DN(hwndDlg);
  3623. if( TRUE == (bValueReturned = Verify_Consumer_DN(hwndDlg) ) )
  3624. {
  3625. /* one of the settings is invalid, stay on this page */
  3626. SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
  3627. }
  3628. break;
  3629. case PSN_QUERYCANCEL:
  3630. // This notification is sent when the user clicks the Cancel button.
  3631. // It is also sent in response to the WM_CLOSE messages issued
  3632. // by PSN_WIZBACK and PSN_WIZNEXT. Make sure that we only process
  3633. // this message if the result is not back or next so that we don't
  3634. // nuke the return value assigned by PSN_WIZBACK or PSN_WIZNEXT.
  3635. //
  3636. // NOTE: To prevent the cancel from occuring, return -1.
  3637. if (mi.m_nResult != NS_WIZBACK && mi.m_nResult != NS_WIZNEXT)
  3638. {
  3639. if (QueryExit(hwndDlg))
  3640. {
  3641. mi.m_nResult = NS_WIZCANCEL;
  3642. }
  3643. else
  3644. {
  3645. SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
  3646. bValueReturned = TRUE;
  3647. }
  3648. }
  3649. break;
  3650. }
  3651. break;
  3652. }
  3653. return bValueReturned;
  3654. }
  3655. //////////////////////////////////////////////////////////////////////////////
  3656. // SetDlgReplDays
  3657. //
  3658. // helper function to convert string to checked days in repl agreement dialog proc
  3659. //
  3660. //
  3661. //
  3662. //
  3663. BOOL SetDlgReplDays(HWND hwndDlg,
  3664. PSZ szReplDays)
  3665. {
  3666. INT Days[7] = {0};
  3667. INT i, tmp=0;
  3668. INT DayControls[] ={IDC_CHECK_SUN, IDC_CHECK_MON, IDC_CHECK_TUE,
  3669. IDC_CHECK_WED, IDC_CHECK_THUR, IDC_CHECK_FRI,
  3670. IDC_CHECK_SAT, -1};
  3671. for(i=0; szReplDays != NULL && szReplDays[i] != '\0'; i++)
  3672. {
  3673. tmp = ( (INT) szReplDays[i] ) - ASCII_ZERO;
  3674. if( tmp >= 0 && tmp < 7)
  3675. {
  3676. CheckDlgButton(hwndDlg, DayControls[tmp], BST_CHECKED);
  3677. }
  3678. }
  3679. return TRUE;
  3680. }
  3681. //////////////////////////////////////////////////////////////////////////////
  3682. // GetDlgReplDays
  3683. //
  3684. // helper function to convert checked days to string for repl agreement dialog procs
  3685. //
  3686. //
  3687. //
  3688. //
  3689. BOOL GetDlgReplDays(HWND hwndDlg,
  3690. PSZ szReplDays)
  3691. {
  3692. INT Days[7] = {0};
  3693. INT i, pos;
  3694. INT DayControls[] ={IDC_CHECK_SUN, IDC_CHECK_MON, IDC_CHECK_TUE,
  3695. IDC_CHECK_WED, IDC_CHECK_THUR, IDC_CHECK_FRI,
  3696. IDC_CHECK_SAT, -1};
  3697. pos=0;
  3698. for(i=0; DayControls[i] != -1; i++)
  3699. {
  3700. if( IsDlgButtonChecked(hwndDlg, DayControls[i]) )
  3701. {
  3702. szReplDays[pos]=(char) (i + ASCII_ZERO);
  3703. pos++;
  3704. }
  3705. }
  3706. szReplDays[pos]='\0';
  3707. return TRUE;
  3708. }
  3709. //////////////////////////////////////////////////////////////////////////////
  3710. // SetDlgReplTimes
  3711. // Initialize Time Controls/Spinners in ReplAgreementDlgProc
  3712. //
  3713. //
  3714. //
  3715. //
  3716. BOOL SetDlgReplTimes(HWND hwndDlg, PSZ szTimes)
  3717. {
  3718. CHAR s_hh[3]="\0", s_mm[3]="\0";
  3719. CHAR e_hh[3]="\0", e_mm[3]="\0";
  3720. INT i;
  3721. for(i=0; i <2; i++)
  3722. {
  3723. s_hh[i] = szTimes[i];
  3724. s_mm[i] = szTimes[i+2];
  3725. e_hh[i] = szTimes[i+5];
  3726. e_mm[i] = szTimes[i+7];
  3727. }
  3728. SetDlgItemText(hwndDlg, IDC_EDIT_REPL_START_TIME_HH, s_hh);
  3729. SetDlgItemText(hwndDlg, IDC_EDIT_REPL_START_TIME_MM, s_mm);
  3730. SetDlgItemText(hwndDlg, IDC_EDIT_REPL_END_TIME_HH, e_hh);
  3731. SetDlgItemText(hwndDlg, IDC_EDIT_REPL_END_TIME_MM, e_mm);
  3732. SendDlgItemMessage(hwndDlg, IDC_SPIN_REPL_START_TIME_HH, UDM_SETBUDDY, (WPARAM)GetDlgItem(hwndDlg, IDC_EDIT_REPL_START_TIME_HH), 0);
  3733. SendDlgItemMessage(hwndDlg, IDC_SPIN_REPL_START_TIME_HH, UDM_SETRANGE, 0, MAKELONG((short)23, (short)0));
  3734. SendDlgItemMessage(hwndDlg, IDC_SPIN_REPL_START_TIME_MM, UDM_SETBUDDY, (WPARAM)GetDlgItem(hwndDlg, IDC_EDIT_REPL_START_TIME_MM), 0);
  3735. SendDlgItemMessage(hwndDlg, IDC_SPIN_REPL_START_TIME_MM, UDM_SETRANGE, 0, MAKELONG((short)59, (short)0));
  3736. SendDlgItemMessage(hwndDlg, IDC_SPIN_REPL_END_TIME_HH, UDM_SETBUDDY, (WPARAM)GetDlgItem(hwndDlg, IDC_EDIT_REPL_END_TIME_HH), 0);
  3737. SendDlgItemMessage(hwndDlg, IDC_SPIN_REPL_END_TIME_HH, UDM_SETRANGE, 0, MAKELONG((short)23, (short)0));
  3738. SendDlgItemMessage(hwndDlg, IDC_SPIN_REPL_END_TIME_MM, UDM_SETBUDDY, (WPARAM)GetDlgItem(hwndDlg, IDC_EDIT_REPL_END_TIME_MM), 0);
  3739. SendDlgItemMessage(hwndDlg, IDC_SPIN_REPL_END_TIME_MM, UDM_SETRANGE, 0, MAKELONG((short)59, (short)0));
  3740. return TRUE;
  3741. }
  3742. //////////////////////////////////////////////////////////////////////////////
  3743. // writeTime
  3744. // make Time Component always be 2 digits
  3745. //
  3746. //
  3747. //
  3748. //
  3749. BOOL writeTime(int nn, char *szTime)
  3750. {
  3751. if( nn > 9)
  3752. {
  3753. sprintf(szTime, "%d", nn);
  3754. }else{
  3755. sprintf(szTime, "0%d", nn);
  3756. }
  3757. return TRUE;
  3758. }
  3759. //////////////////////////////////////////////////////////////////////////////
  3760. // GetDlgReplTimes
  3761. // Get Repl Times From the Dialog
  3762. //
  3763. //
  3764. //
  3765. //
  3766. BOOL GetDlgReplTimes(HWND hwndDlg, PSZ szTimes)
  3767. {
  3768. CHAR s_hh[3]="\0", s_mm[3]="\0";
  3769. CHAR e_hh[3]="\0", e_mm[3]="\0";
  3770. INT ns_hh, ns_mm;
  3771. INT ne_hh, ne_mm;
  3772. BOOL bTrans;
  3773. ns_hh = GetDlgItemInt(hwndDlg, IDC_EDIT_REPL_START_TIME_HH, &bTrans, FALSE);
  3774. ns_mm = GetDlgItemInt(hwndDlg, IDC_EDIT_REPL_START_TIME_MM, &bTrans, FALSE);
  3775. ne_hh = GetDlgItemInt(hwndDlg, IDC_EDIT_REPL_END_TIME_HH, &bTrans, FALSE);
  3776. ne_mm = GetDlgItemInt(hwndDlg, IDC_EDIT_REPL_END_TIME_MM, &bTrans, FALSE);
  3777. writeTime(ns_hh, s_hh);
  3778. writeTime(ns_mm, s_mm);
  3779. writeTime(ne_hh, e_hh);
  3780. writeTime(ne_mm, e_mm);
  3781. sprintf(szTimes, "%s%s-%s%s", s_hh, s_mm, e_hh, e_mm);
  3782. return TRUE;
  3783. }
  3784. //////////////////////////////////////////////////////////////////////////////
  3785. // SaveDlgReplAgreement
  3786. //
  3787. // save information for replication agreements from dialog
  3788. //
  3789. //
  3790. //
  3791. void SaveDlgReplAgreement(HWND hwndDlg,
  3792. PSZ pszReplHost,
  3793. INT *pnReplPort,
  3794. PSZ pszReplRoot,
  3795. PSZ pszReplBindAs,
  3796. PSZ pszReplPw,
  3797. PSZ pszReplDays,
  3798. PSZ pszReplTimes)
  3799. {
  3800. SaveDlgServerInfo(hwndDlg,
  3801. pszReplHost,
  3802. pnReplPort,
  3803. pszReplRoot,
  3804. pszReplBindAs,
  3805. pszReplPw);
  3806. /* get replication days */
  3807. GetDlgReplDays(hwndDlg, pszReplDays);
  3808. /* get replication times */
  3809. GetDlgReplTimes(hwndDlg, pszReplTimes);
  3810. }
  3811. //////////////////////////////////////////////////////////////////////////////
  3812. // LoadDlgReplAgreement
  3813. //
  3814. //load information for replication agreements into dialog
  3815. //
  3816. //
  3817. //
  3818. void LoadDlgReplAgreement(HWND hwndDlg,
  3819. PSZ pszReplHost,
  3820. INT nReplPort,
  3821. PSZ pszReplRoot,
  3822. PSZ pszReplBindAs,
  3823. PSZ pszReplPw,
  3824. PSZ pszReplDays,
  3825. PSZ pszReplTimes)
  3826. {
  3827. LoadDlgServerInfo(hwndDlg,
  3828. pszReplHost,
  3829. nReplPort,
  3830. pszReplRoot,
  3831. pszReplBindAs,
  3832. pszReplPw);
  3833. SetDlgReplDays(hwndDlg, pszReplDays);
  3834. /* get replication times */
  3835. SetDlgReplTimes(hwndDlg, pszReplTimes);
  3836. }
  3837. //////////////////////////////////////////////////////////////////////////////
  3838. // VerifyReplAgreement
  3839. //
  3840. // Verify replication agreement
  3841. //
  3842. // Returns TRUE if there is an invalid setting
  3843. // Returns False if all settings are valid
  3844. //
  3845. // SideEffect: displays error (or writes to log in silent mode)
  3846. BOOL VerifyReplAgreement( PSZ pszReplHost,
  3847. INT *pnReplPort,
  3848. PSZ pszReplRoot,
  3849. PSZ pszReplBindAs,
  3850. PSZ pszReplPw,
  3851. PSZ pszReplDays,
  3852. PSZ pszReplTimes)
  3853. {
  3854. BOOL bValueReturned = FALSE;
  3855. if( TRUE == (bValueReturned = VerifyServerInfo(pszReplHost,
  3856. pnReplPort,
  3857. pszReplRoot,
  3858. pszReplBindAs,
  3859. pszReplPw,
  3860. TRUE) ) )
  3861. {
  3862. /* problem with the server info, just return true for Error */
  3863. } else if (FALSE == FullyQualifyHostName(pszReplHost) )
  3864. {
  3865. /* can't qualify host name, must be invalid */
  3866. DSMessageBoxOK(ERR_INVALID_HOST_TITLE, ERR_INVALID_HOST,
  3867. pszReplHost, pszReplHost);
  3868. bValueReturned = TRUE;
  3869. } else if (FALSE == UTF8IsValidLdapUser( pszReplHost,
  3870. *pnReplPort,
  3871. pszReplRoot,
  3872. pszReplBindAs,
  3873. pszReplPw,
  3874. FALSE) )
  3875. {
  3876. /* can't bind to host with info entered */
  3877. if( IDNO == DSMessageBox(MB_YESNO, ERR_CANT_FIND_DS_REPL_TITLE,
  3878. ERR_CANT_FIND_DS_REPL, 0, pszReplHost,
  3879. *pnReplPort, pszReplBindAs) )
  3880. {
  3881. /* user wants to stay on this page and fix value, otherwise,
  3882. allows them to continue even though cant find host
  3883. for replication */
  3884. bValueReturned = TRUE;
  3885. }
  3886. }
  3887. /* may want to add more verification here */
  3888. return bValueReturned;
  3889. }
  3890. //////////////////////////////////////////////////////////////////////////////
  3891. // Supplier_Replication_Agreement_DialogProc
  3892. //
  3893. // get information for replication agreements
  3894. //
  3895. //
  3896. //
  3897. //
  3898. static BOOL CALLBACK
  3899. Supplier_Replication_Agreement_DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  3900. {
  3901. BOOL bValueReturned = FALSE;
  3902. UINT uResult = 0;
  3903. BOOL bResult = FALSE;
  3904. HWND hCtrl;
  3905. /* list of controls to be setup for 8bit input/display */
  3906. INT h8bitControls[]={IDC_EDIT_HOST,
  3907. IDC_EDIT_SUFFIX,
  3908. IDC_EDIT_BIND_AS,
  3909. IDC_EDIT_PW,
  3910. -1};
  3911. switch (uMsg)
  3912. {
  3913. case WM_INITDIALOG:
  3914. // This message is sent when the property page is first created. Here
  3915. // you can perform any one time initialization that you require.
  3916. Setup8bitInputDisplay(hwndDlg, h8bitControls);
  3917. break;
  3918. case WM_COMMAND:
  3919. // Windows sends WM_COMMAND messages whenever the user clicks on
  3920. // a control in your property page. If you need to perform some
  3921. // special action, such as validating data or responding to a
  3922. // button click, do it here.
  3923. break;
  3924. case WM_NOTIFY:
  3925. // Windows sends WM_NOTIFY messages to your property page whenever
  3926. // something interesting happens to the page. This could be page
  3927. // activation/deactivation, a button click, etc. The wParam parameter
  3928. // contains a pointer to the property page. The lParam parameter
  3929. // contains a pointer to an NMHDR structure. The code field of this
  3930. // structure contains the notification message code being sent. The
  3931. // property sheet API allows you to alter the behavior of these
  3932. // messages by returning a value for each message. To return a value,
  3933. // use the SetWindowLong Windows SDK function.
  3934. switch (((NMHDR*)lParam)->code)
  3935. {
  3936. case PSN_SETACTIVE:
  3937. // This notification is sent upon activation of the property page.
  3938. // The property sheet should be centered each time it is activated
  3939. // in case the user has moved the stupid thing (this duplicates
  3940. // InstallShield functionality). You should also set the state of
  3941. // the wizard buttons here.
  3942. //
  3943. // NOTE: If you do not wish this page to become active, return -1.
  3944. /* stevross: will have to come back to display this twice for middle case */
  3945. if( SUPPLIER_SIR_REPLICATION != mi.m_nSetupSupplierReplication )
  3946. {
  3947. /* we only setup replication agreements for SUPPLIER SIR */
  3948. SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
  3949. return TRUE;
  3950. }
  3951. /* set text to say Supplier Repl Agreement */
  3952. SetDlgItemText(hwndDlg, IDC_STATIC_REPLICATION_AGREEMENT, SUPPLIER_REPL_AGREE);
  3953. /* display values */
  3954. LoadDlgReplAgreement(hwndDlg,
  3955. mi.m_szSupplierHost,
  3956. mi.m_nSupplierPort,
  3957. mi.m_szSupplierRoot,
  3958. mi.m_szSupplierBindAs,
  3959. mi.m_szSupplierPw,
  3960. mi.m_szSIRDays,
  3961. mi.m_szSIRTimes);
  3962. /* hide the repl sync interval stuff because it only makes since for CIR */
  3963. hCtrl = GetDlgItem(hwndDlg, IDC_EDIT_REPL_SYNC_INTERVAL);
  3964. ShowWindow(hCtrl,SW_HIDE);
  3965. hCtrl = GetDlgItem(hwndDlg, IDC_STATIC_REPL_SYNC);
  3966. ShowWindow(hCtrl,SW_HIDE);
  3967. hCtrl = GetDlgItem(hwndDlg, IDC_SPIN_REPL_SYNC_INTERVAL);
  3968. ShowWindow(hCtrl,SW_HIDE);
  3969. /* center window n stuff */
  3970. CenterWindow(GetParent(hwndDlg));
  3971. PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
  3972. break;
  3973. case PSN_KILLACTIVE:
  3974. // This notification is sent upon deactivation of the property page.
  3975. // Here you can do whatever might be necessary for this action, such
  3976. // as saving the state of the controls. You should also reset the
  3977. // the state of the wizard buttons here, as both the Back and Next
  3978. // buttons should be active when you leave the AskOptions function.
  3979. //
  3980. // NOTE: If you do not want the page deactivated, return -1.
  3981. PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
  3982. break;
  3983. case PSN_WIZBACK:
  3984. // The user clicked the back button from the first property page.
  3985. // Set the result code NS_WIZBACK to indicate this action and close
  3986. // the property sheet using brute force. If this procedure is not
  3987. // being used by the first property sheet, you should ignore this
  3988. // notification and simply let windows go to the previous page.
  3989. //
  3990. // NOTE: To prevent the wizard from stepping back, return -1.
  3991. SaveDlgReplAgreement(hwndDlg,
  3992. mi.m_szSupplierHost,
  3993. &mi.m_nSupplierPort,
  3994. mi.m_szSupplierRoot,
  3995. mi.m_szSupplierBindAs,
  3996. mi.m_szSupplierPw,
  3997. mi.m_szSIRDays,
  3998. mi.m_szSIRTimes);
  3999. break;
  4000. case PSN_WIZNEXT:
  4001. // The user clicked the next button from the last property page.
  4002. // Set the result code NS_WIZNEXT to indicate this action and close
  4003. // the property sheet using brute force. If this procedure is not
  4004. // being used by the last property sheet, you should ignore this
  4005. // notification and simply let windows go to the next page.
  4006. //
  4007. // NOTE: To prevent the wizard from stepping ahead, return -1.
  4008. /* only bother to check passwords if username is valid */
  4009. SaveDlgReplAgreement(hwndDlg,
  4010. mi.m_szSupplierHost,
  4011. &mi.m_nSupplierPort,
  4012. mi.m_szSupplierRoot,
  4013. mi.m_szSupplierBindAs,
  4014. mi.m_szSupplierPw,
  4015. mi.m_szSIRDays,
  4016. mi.m_szSIRTimes);
  4017. if( TRUE == (bValueReturned = VerifyReplAgreement(mi.m_szSupplierHost,
  4018. &mi.m_nSupplierPort,
  4019. mi.m_szSupplierRoot,
  4020. mi.m_szSupplierBindAs,
  4021. mi.m_szSupplierPw,
  4022. mi.m_szSIRDays,
  4023. mi.m_szSIRTimes) ) )
  4024. {
  4025. /* one of the settings is invalid, stay on this page */
  4026. SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
  4027. }
  4028. break;
  4029. case PSN_QUERYCANCEL:
  4030. // This notification is sent when the user clicks the Cancel button.
  4031. // It is also sent in response to the WM_CLOSE messages issued
  4032. // by PSN_WIZBACK and PSN_WIZNEXT. Make sure that we only process
  4033. // this message if the result is not back or next so that we don't
  4034. // nuke the return value assigned by PSN_WIZBACK or PSN_WIZNEXT.
  4035. //
  4036. // NOTE: To prevent the cancel from occuring, return -1.
  4037. if (mi.m_nResult != NS_WIZBACK && mi.m_nResult != NS_WIZNEXT)
  4038. {
  4039. if (QueryExit(hwndDlg))
  4040. {
  4041. mi.m_nResult = NS_WIZCANCEL;
  4042. }
  4043. else
  4044. {
  4045. SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
  4046. bValueReturned = TRUE;
  4047. }
  4048. }
  4049. break;
  4050. }
  4051. break;
  4052. }
  4053. return bValueReturned;
  4054. }
  4055. //////////////////////////////////////////////////////////////////////////////
  4056. // SaveDlgInput_Consumer_Replication_Agreement_DialogProc
  4057. //
  4058. // get info for consumer replication agreements
  4059. //
  4060. //
  4061. //
  4062. //
  4063. void SaveDlgInput_Consumer_Replication_Agreement(HWND hwndDlg)
  4064. {
  4065. BOOL bTrans;
  4066. SaveDlgReplAgreement(hwndDlg,
  4067. mi.m_szConsumerHost,
  4068. &mi.m_nConsumerPort,
  4069. mi.m_szConsumerRoot,
  4070. mi.m_szConsumerBindAs,
  4071. mi.m_szConsumerPw,
  4072. mi.m_szCIRDays,
  4073. mi.m_szCIRTimes);
  4074. /* get the CIR Interval */
  4075. mi.m_nCIRInterval = GetDlgItemInt(hwndDlg, IDC_EDIT_REPL_SYNC_INTERVAL, &bTrans , FALSE);
  4076. }
  4077. //////////////////////////////////////////////////////////////////////////////
  4078. // Consumer_Replication_Agreement_DialogProc
  4079. //
  4080. // get information for replication agreements
  4081. //
  4082. //
  4083. //
  4084. //
  4085. static BOOL CALLBACK
  4086. Consumer_Replication_Agreement_DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  4087. {
  4088. BOOL bValueReturned = FALSE;
  4089. UINT uResult = 0;
  4090. BOOL bResult = FALSE;
  4091. /* list of controls to be setup for 8bit input/display */
  4092. INT h8bitControls[]={IDC_EDIT_HOST,
  4093. IDC_EDIT_SUFFIX,
  4094. IDC_EDIT_BIND_AS,
  4095. IDC_EDIT_PW,
  4096. -1};
  4097. switch (uMsg)
  4098. {
  4099. case WM_INITDIALOG:
  4100. // This message is sent when the property page is first created. Here
  4101. // you can perform any one time initialization that you require.
  4102. Setup8bitInputDisplay(hwndDlg, h8bitControls);
  4103. SendDlgItemMessage(hwndDlg, IDC_SPIN_REPL_SYNC_INTERVAL, UDM_SETBUDDY, (WPARAM)GetDlgItem(hwndDlg, IDC_EDIT_REPL_SYNC_INTERVAL), 0);
  4104. SendDlgItemMessage(hwndDlg, IDC_SPIN_REPL_SYNC_INTERVAL, UDM_SETRANGE, 0, MAKELONG((short)59, (short)0));
  4105. break;
  4106. case WM_COMMAND:
  4107. // Windows sends WM_COMMAND messages whenever the user clicks on
  4108. // a control in your property page. If you need to perform some
  4109. // special action, such as validating data or responding to a
  4110. // button click, do it here.
  4111. break;
  4112. case WM_NOTIFY:
  4113. // Windows sends WM_NOTIFY messages to your property page whenever
  4114. // something interesting happens to the page. This could be page
  4115. // activation/deactivation, a button click, etc. The wParam parameter
  4116. // contains a pointer to the property page. The lParam parameter
  4117. // contains a pointer to an NMHDR structure. The code field of this
  4118. // structure contains the notification message code being sent. The
  4119. // property sheet API allows you to alter the behavior of these
  4120. // messages by returning a value for each message. To return a value,
  4121. // use the SetWindowLong Windows SDK function.
  4122. switch (((NMHDR*)lParam)->code)
  4123. {
  4124. case PSN_SETACTIVE:
  4125. // This notification is sent upon activation of the property page.
  4126. // The property sheet should be centered each time it is activated
  4127. // in case the user has moved the stupid thing (this duplicates
  4128. // InstallShield functionality). You should also set the state of
  4129. // the wizard buttons here.
  4130. //
  4131. // NOTE: If you do not wish this page to become active, return -1.
  4132. /* stevross: will have to come back to display this twice for middle case */
  4133. if( CONSUMER_CIR_REPLICATION != mi.m_nSetupConsumerReplication )
  4134. {
  4135. /* we only setup replication agreements for CONSUMER CIR */
  4136. SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
  4137. return TRUE;
  4138. }
  4139. /* make title consumer replication agreement */
  4140. SetDlgItemText(hwndDlg, IDC_STATIC_REPLICATION_AGREEMENT, CONSUMER_REPL_AGREE);
  4141. /* display values */
  4142. LoadDlgReplAgreement(hwndDlg,
  4143. mi.m_szConsumerHost,
  4144. mi.m_nConsumerPort,
  4145. mi.m_szConsumerRoot,
  4146. mi.m_szConsumerBindAs,
  4147. mi.m_szConsumerPw,
  4148. mi.m_szCIRDays,
  4149. mi.m_szCIRTimes);
  4150. SetDlgItemInt(hwndDlg, IDC_EDIT_REPL_SYNC_INTERVAL, mi.m_nCIRInterval, FALSE);
  4151. CenterWindow(GetParent(hwndDlg));
  4152. PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
  4153. break;
  4154. case PSN_KILLACTIVE:
  4155. // This notification is sent upon deactivation of the property page.
  4156. // Here you can do whatever might be necessary for this action, such
  4157. // as saving the state of the controls. You should also reset the
  4158. // the state of the wizard buttons here, as both the Back and Next
  4159. // buttons should be active when you leave the AskOptions function.
  4160. //
  4161. // NOTE: If you do not want the page deactivated, return -1.
  4162. PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
  4163. break;
  4164. case PSN_WIZBACK:
  4165. // The user clicked the back button from the first property page.
  4166. // Set the result code NS_WIZBACK to indicate this action and close
  4167. // the property sheet using brute force. If this procedure is not
  4168. // being used by the first property sheet, you should ignore this
  4169. // notification and simply let windows go to the previous page.
  4170. //
  4171. // NOTE: To prevent the wizard from stepping back, return -1.
  4172. SaveDlgInput_Consumer_Replication_Agreement(hwndDlg);
  4173. break;
  4174. case PSN_WIZNEXT:
  4175. // The user clicked the next button from the last property page.
  4176. // Set the result code NS_WIZNEXT to indicate this action and close
  4177. // the property sheet using brute force. If this procedure is not
  4178. // being used by the last property sheet, you should ignore this
  4179. // notification and simply let windows go to the next page.
  4180. //
  4181. // NOTE: To prevent the wizard from stepping ahead, return -1.
  4182. /* only bother to check passwords if username is valid */
  4183. SaveDlgInput_Consumer_Replication_Agreement(hwndDlg);
  4184. if( TRUE == (bValueReturned = VerifyReplAgreement(mi.m_szConsumerHost,
  4185. &mi.m_nConsumerPort,
  4186. mi.m_szConsumerRoot,
  4187. mi.m_szConsumerBindAs,
  4188. mi.m_szConsumerPw,
  4189. mi.m_szCIRDays,
  4190. mi.m_szCIRTimes) ) )
  4191. {
  4192. /* one of the settings invalid, stay on this page */
  4193. SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
  4194. }
  4195. break;
  4196. case PSN_QUERYCANCEL:
  4197. // This notification is sent when the user clicks the Cancel button.
  4198. // It is also sent in response to the WM_CLOSE messages issued
  4199. // by PSN_WIZBACK and PSN_WIZNEXT. Make sure that we only process
  4200. // this message if the result is not back or next so that we don't
  4201. // nuke the return value assigned by PSN_WIZBACK or PSN_WIZNEXT.
  4202. //
  4203. // NOTE: To prevent the cancel from occuring, return -1.
  4204. if (mi.m_nResult != NS_WIZBACK && mi.m_nResult != NS_WIZNEXT)
  4205. {
  4206. if (QueryExit(hwndDlg))
  4207. {
  4208. mi.m_nResult = NS_WIZCANCEL;
  4209. }
  4210. else
  4211. {
  4212. SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
  4213. bValueReturned = TRUE;
  4214. }
  4215. }
  4216. break;
  4217. }
  4218. break;
  4219. }
  4220. return bValueReturned;
  4221. }
  4222. //////////////////////////////////////////////////////////////////////////////
  4223. // Sample_Entries_Org_DialogProc
  4224. //
  4225. // ask user if they want to populate with sample entries and sample organization
  4226. //
  4227. //
  4228. //
  4229. //
  4230. static BOOL CALLBACK
  4231. Sample_Entries_Org_DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  4232. {
  4233. BOOL bValueReturned = FALSE;
  4234. UINT uResult = 0;
  4235. BOOL bResult = FALSE;
  4236. CHAR szMustHaveBase[MAX_STR_SIZE]="\0";
  4237. static CHAR szCustomFileName[MAX_STR_SIZE]="\0";
  4238. static CHAR szSampleFileName[MAX_STR_SIZE]="\0";
  4239. /* list of controls to be setup for 8bit input/display */
  4240. INT h8bitControls[]={IDC_STATIC_MUST_HAVE_BASE,
  4241. IDC_STATIC_LDIF_FILE_NAME,
  4242. -1};
  4243. switch (uMsg)
  4244. {
  4245. case WM_INITDIALOG:
  4246. // This message is sent when the property page is first created. Here
  4247. // you can perform any one time initialization that you require.
  4248. /* default is to populate with sample entries */
  4249. Setup8bitInputDisplay(hwndDlg, h8bitControls);
  4250. break;
  4251. case WM_COMMAND:
  4252. // Windows sends WM_COMMAND messages whenever the user clicks on
  4253. // a control in your property page. If you need to perform some
  4254. // special action, such as validating data or responding to a
  4255. // button click, do it here.
  4256. switch (LOWORD(wParam))
  4257. {
  4258. case IDC_BUTTON_CHOOSE_LDIF_FILE:
  4259. GetFileName(hwndDlg, "Choose ldif file to import",
  4260. "Ldif Files|*.ldif|All Files|*.*|",
  4261. NULL, szCustomFileName, MAX_PATH );
  4262. /* assume by browsing user will want this file so check custom radio button for them
  4263. and set file to be displayed */
  4264. my_snprintf(mi.m_szPopLdifFile, sizeof(mi.m_szPopLdifFile), "%s", szCustomFileName);
  4265. CheckRadioButton(hwndDlg, IDC_RADIO_DONT_POPULATE, IDC_RADIO_POPULATE_CUSTOM, IDC_RADIO_POPULATE_CUSTOM);
  4266. default:
  4267. mi.m_nPopulateSampleOrg = (int )(BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_CHECK_POPULATE_ORG_ENTRIES ) );
  4268. if( BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_RADIO_POPULATE_SAMPLE ) )
  4269. {
  4270. mi.m_nPopulateSampleEntries = 1;
  4271. my_snprintf(mi.m_szPopLdifFile, sizeof(mi.m_szPopLdifFile), "%s", szSampleFileName);
  4272. }else if( BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_RADIO_POPULATE_CUSTOM ) ){
  4273. mi.m_nPopulateSampleEntries = 0;
  4274. mi.m_nPopulateSampleOrg = 1;
  4275. // my_snprintf(mi.m_szPopLdifFile, sizeof(mi.m_szPopLdifFile), "%s", szCustomFileName);
  4276. }else{
  4277. mi.m_nPopulateSampleEntries = 0;
  4278. my_snprintf(mi.m_szPopLdifFile, sizeof(mi.m_szPopLdifFile), "\0");
  4279. }
  4280. break;
  4281. }
  4282. /* update ldif file name if changed */
  4283. SetDlgItemText(hwndDlg, IDC_STATIC_LDIF_FILE_NAME, mi.m_szPopLdifFile);
  4284. break;
  4285. case WM_NOTIFY:
  4286. // Windows sends WM_NOTIFY messages to your property page whenever
  4287. // something interesting happens to the page. This could be page
  4288. // activation/deactivation, a button click, etc. The wParam parameter
  4289. // contains a pointer to the property page. The lParam parameter
  4290. // contains a pointer to an NMHDR structure. The code field of this
  4291. // structure contains the notification message code being sent. The
  4292. // property sheet API allows you to alter the behavior of these
  4293. // messages by returning a value for each message. To return a value,
  4294. // use the SetWindowLong Windows SDK function.
  4295. switch (((NMHDR*)lParam)->code)
  4296. {
  4297. case PSN_SETACTIVE:
  4298. // This notification is sent upon activation of the property page.
  4299. // The property sheet should be centered each time it is activated
  4300. // in case the user has moved the stupid thing (this duplicates
  4301. // InstallShield functionality). You should also set the state of
  4302. // the wizard buttons here.
  4303. //
  4304. // NOTE: If you do not wish this page to become active, return -1.
  4305. if( (CONSUMER_CIR_REPLICATION == mi.m_nSetupConsumerReplication)
  4306. || (CONSUMER_SIR_REPLICATION == mi.m_nSetupConsumerReplication ) )
  4307. {
  4308. /* we only want to populate if they are not doing CIR */
  4309. SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
  4310. return TRUE;
  4311. }
  4312. /* warn user about suffix and database import */
  4313. my_snprintf(szMustHaveBase, sizeof(szMustHaveBase), "(note: must have base %s)", mi.m_szInstanceSuffix );
  4314. SetDlgItemText(hwndDlg, IDC_STATIC_MUST_HAVE_BASE, szMustHaveBase);
  4315. my_snprintf(szSampleFileName, sizeof(szSampleFileName), "%s\\%s", TARGETDIR, SAMPLE_LDIF);
  4316. if(mi.m_nExistingUG == 0)
  4317. {
  4318. /* the user is creating a new UG with this instance */
  4319. /* create ou=People/ou=Groups */
  4320. // mi.m_nPopulateSampleOrg = 1;
  4321. // lstrcpy(mi.m_szPopLdifFile, SUGGEST_LDIF);
  4322. }
  4323. if(mi.m_nPopulateSampleEntries)
  4324. {
  4325. CheckRadioButton(hwndDlg, IDC_RADIO_DONT_POPULATE,
  4326. IDC_RADIO_POPULATE_CUSTOM,
  4327. IDC_RADIO_POPULATE_SAMPLE);
  4328. } else if (mi.m_szPopLdifFile[0]) {
  4329. CheckRadioButton(hwndDlg, IDC_RADIO_DONT_POPULATE,
  4330. IDC_RADIO_POPULATE_CUSTOM,
  4331. IDC_RADIO_POPULATE_CUSTOM);
  4332. } else {
  4333. CheckRadioButton(hwndDlg, IDC_RADIO_DONT_POPULATE,
  4334. IDC_RADIO_POPULATE_CUSTOM,
  4335. IDC_RADIO_DONT_POPULATE);
  4336. }
  4337. if(mi.m_nPopulateSampleOrg)
  4338. {
  4339. CheckDlgButton(hwndDlg, IDC_CHECK_POPULATE_ORG_ENTRIES, BST_CHECKED);
  4340. }
  4341. SetDlgItemText(hwndDlg, IDC_STATIC_LDIF_FILE_NAME, mi.m_szPopLdifFile);
  4342. CenterWindow(GetParent(hwndDlg));
  4343. PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
  4344. break;
  4345. case PSN_KILLACTIVE:
  4346. // This notification is sent upon deactivation of the property page.
  4347. // Here you can do whatever might be necessary for this action, such
  4348. // as saving the state of the controls. You should also reset the
  4349. // the state of the wizard buttons here, as both the Back and Next
  4350. // buttons should be active when you leave the AskOptions function.
  4351. //
  4352. // NOTE: If you do not want the page deactivated, return -1.
  4353. PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
  4354. break;
  4355. case PSN_WIZBACK:
  4356. // The user clicked the back button from the first property page.
  4357. // Set the result code NS_WIZBACK to indicate this action and close
  4358. // the property sheet using brute force. If this procedure is not
  4359. // being used by the first property sheet, you should ignore this
  4360. // notification and simply let windows go to the previous page.
  4361. //
  4362. // NOTE: To prevent the wizard from stepping back, return -1.
  4363. /* all settings for this dailog are saved in WM_COMMAND processing */
  4364. break;
  4365. case PSN_WIZNEXT:
  4366. // The user clicked the next button from the last property page.
  4367. // Set the result code NS_WIZNEXT to indicate this action and close
  4368. // the property sheet using brute force. If this procedure is not
  4369. // being used by the last property sheet, you should ignore this
  4370. // notification and simply let windows go to the next page.
  4371. //
  4372. // NOTE: To prevent the wizard from stepping ahead, return -1.
  4373. /* all settings for this dailog are saved in WM_COMMAND processing */
  4374. break;
  4375. case PSN_QUERYCANCEL:
  4376. // This notification is sent when the user clicks the Cancel button.
  4377. // It is also sent in response to the WM_CLOSE messages issued
  4378. // by PSN_WIZBACK and PSN_WIZNEXT. Make sure that we only process
  4379. // this message if the result is not back or next so that we don't
  4380. // nuke the return value assigned by PSN_WIZBACK or PSN_WIZNEXT.
  4381. //
  4382. // NOTE: To prevent the cancel from occuring, return -1.
  4383. if (mi.m_nResult != NS_WIZBACK && mi.m_nResult != NS_WIZNEXT)
  4384. {
  4385. if (QueryExit(hwndDlg))
  4386. {
  4387. mi.m_nResult = NS_WIZCANCEL;
  4388. }
  4389. else
  4390. {
  4391. SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
  4392. bValueReturned = TRUE;
  4393. }
  4394. }
  4395. break;
  4396. }
  4397. break;
  4398. }
  4399. return bValueReturned;
  4400. }
  4401. //////////////////////////////////////////////////////////////////////////////
  4402. // Disable_Schema_Checking_DialogProc
  4403. //
  4404. // ask user if they want to disable schema checking
  4405. //
  4406. //
  4407. //
  4408. //
  4409. static BOOL CALLBACK
  4410. Disable_Schema_Checking_DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  4411. {
  4412. BOOL bValueReturned = FALSE;
  4413. UINT uResult = 0;
  4414. BOOL bResult = FALSE;
  4415. switch (uMsg)
  4416. {
  4417. case WM_INITDIALOG:
  4418. // This message is sent when the property page is first created. Here
  4419. // you can perform any one time initialization that you require.
  4420. /* default is to populate with sample entries */
  4421. break;
  4422. case WM_COMMAND:
  4423. // Windows sends WM_COMMAND messages whenever the user clicks on
  4424. // a control in your property page. If you need to perform some
  4425. // special action, such as validating data or responding to a
  4426. // button click, do it here.
  4427. switch (LOWORD(wParam))
  4428. {
  4429. default:
  4430. mi.m_nDisableSchemaChecking = (int )(BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_CHECK_DISABLE_SCHEMA_CHECKING ) );
  4431. break;
  4432. }
  4433. break;
  4434. case WM_NOTIFY:
  4435. // Windows sends WM_NOTIFY messages to your property page whenever
  4436. // something interesting happens to the page. This could be page
  4437. // activation/deactivation, a button click, etc. The wParam parameter
  4438. // contains a pointer to the property page. The lParam parameter
  4439. // contains a pointer to an NMHDR structure. The code field of this
  4440. // structure contains the notification message code being sent. The
  4441. // property sheet API allows you to alter the behavior of these
  4442. // messages by returning a value for each message. To return a value,
  4443. // use the SetWindowLong Windows SDK function.
  4444. switch (((NMHDR*)lParam)->code)
  4445. {
  4446. case PSN_SETACTIVE:
  4447. // This notification is sent upon activation of the property page.
  4448. // The property sheet should be centered each time it is activated
  4449. // in case the user has moved the stupid thing (this duplicates
  4450. // InstallShield functionality). You should also set the state of
  4451. // the wizard buttons here.
  4452. //
  4453. // NOTE: If you do not wish this page to become active, return -1.
  4454. if(mi.m_nDisableSchemaChecking)
  4455. {
  4456. CheckDlgButton(hwndDlg, IDC_CHECK_DISABLE_SCHEMA_CHECKING, BST_CHECKED);
  4457. }
  4458. CenterWindow(GetParent(hwndDlg));
  4459. PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
  4460. break;
  4461. case PSN_KILLACTIVE:
  4462. // This notification is sent upon deactivation of the property page.
  4463. // Here you can do whatever might be necessary for this action, such
  4464. // as saving the state of the controls. You should also reset the
  4465. // the state of the wizard buttons here, as both the Back and Next
  4466. // buttons should be active when you leave the AskOptions function.
  4467. //
  4468. // NOTE: If you do not want the page deactivated, return -1.
  4469. PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
  4470. break;
  4471. case PSN_WIZBACK:
  4472. // The user clicked the back button from the first property page.
  4473. // Set the result code NS_WIZBACK to indicate this action and close
  4474. // the property sheet using brute force. If this procedure is not
  4475. // being used by the first property sheet, you should ignore this
  4476. // notification and simply let windows go to the previous page.
  4477. //
  4478. // NOTE: To prevent the wizard from stepping back, return -1.
  4479. /* all settings for this dailog are saved in WM_COMMAND processing */
  4480. break;
  4481. case PSN_WIZNEXT:
  4482. // The user clicked the next button from the last property page.
  4483. // Set the result code NS_WIZNEXT to indicate this action and close
  4484. // the property sheet using brute force. If this procedure is not
  4485. // being used by the last property sheet, you should ignore this
  4486. // notification and simply let windows go to the next page.
  4487. //
  4488. // NOTE: To prevent the wizard from stepping ahead, return -1.
  4489. /* this is the last property page of advanced mode whenever we display it*/
  4490. mi.m_nResult = NS_WIZNEXT;
  4491. SendMessage(GetParent(hwndDlg), WM_CLOSE, 0, 0);
  4492. /* all settings for this dailog are saved in WM_COMMAND processing */
  4493. break;
  4494. case PSN_QUERYCANCEL:
  4495. // This notification is sent when the user clicks the Cancel button.
  4496. // It is also sent in response to the WM_CLOSE messages issued
  4497. // by PSN_WIZBACK and PSN_WIZNEXT. Make sure that we only process
  4498. // this message if the result is not back or next so that we don't
  4499. // nuke the return value assigned by PSN_WIZBACK or PSN_WIZNEXT.
  4500. //
  4501. // NOTE: To prevent the cancel from occuring, return -1.
  4502. if (mi.m_nResult != NS_WIZBACK && mi.m_nResult != NS_WIZNEXT)
  4503. {
  4504. if (QueryExit(hwndDlg))
  4505. {
  4506. mi.m_nResult = NS_WIZCANCEL;
  4507. }
  4508. else
  4509. {
  4510. SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
  4511. bValueReturned = TRUE;
  4512. }
  4513. }
  4514. break;
  4515. }
  4516. break;
  4517. }
  4518. return bValueReturned;
  4519. }
  4520. void initialize_module()
  4521. {
  4522. mi.m_nResult = 0;
  4523. mi.m_szMCCBindAs = NULL;
  4524. mi.m_nInstanceServerPort = 0;
  4525. mi.m_nAdminServerPort = 0;
  4526. mi.m_nCfgSspt = 0;
  4527. mi.m_nPopulateSampleEntries = 0;
  4528. mi.m_nPopulateSampleOrg = 1;
  4529. mi.m_nSetupConsumerReplication = 0;
  4530. mi.m_nSetupSupplierReplication = 0;
  4531. mi.m_nMaxChangeLogRecords = 0;
  4532. mi.m_nMaxChangeLogAge = 0;
  4533. mi.m_nChangeLogAgeMagnitude = 0;
  4534. mi.m_nConsumerSSL = 0;
  4535. mi.m_nSupplierSSL = 0;
  4536. mi.m_nUseSupplierSettings = 0;
  4537. mi.m_nUseChangeLogSettings = 0;
  4538. mi.m_nCIRInterval = 0;
  4539. mi.m_nConsumerPort = 0;
  4540. mi.m_nSupplierPort = 0;
  4541. mi.m_nMCCPort = 0;
  4542. mi.m_nExistingMCC = 0;
  4543. mi.m_nUGPort = 0;
  4544. mi.m_nExistingUG = 0;
  4545. mi.m_nDisableSchemaChecking = 0;
  4546. mi.m_nSNMPOn = 0;
  4547. mi.m_nConfigConsumerDN = 0;
  4548. memset(mi.m_szMCCPw, '\0', MAX_STR_SIZE);
  4549. memset(mi.m_szMCCHost, '\0', MAX_STR_SIZE);
  4550. memset(mi.m_szMCCSuffix, '\0', MAX_STR_SIZE);
  4551. memset(mi.m_szUGPw, '\0', MAX_STR_SIZE);
  4552. memset(mi.m_szUGHost, '\0', MAX_STR_SIZE);
  4553. memset(mi.m_szUGSuffix, '\0', MAX_STR_SIZE);
  4554. memset(mi.m_szAdminDomain, '\0', MAX_STR_SIZE);
  4555. memset(mi.m_szLdapURL, '\0', MAX_STR_SIZE);
  4556. memset(mi.m_szUserGroupURL, '\0', MAX_STR_SIZE);
  4557. memset(mi.m_szUserGroupAdmin, '\0', MAX_STR_SIZE);
  4558. memset(mi.m_szUserGroupAdminPW, '\0', MAX_STR_SIZE);
  4559. memset(mi.m_szInstallDN, '\0', MAX_STR_SIZE);
  4560. memset(mi.m_szSsptUid, '\0', MAX_STR_SIZE);
  4561. memset(mi.m_szSsptUidPw, '\0', MAX_STR_SIZE);
  4562. memset(mi.m_szSsptUidPwAgain, '\0', MAX_STR_SIZE);
  4563. memset(mi.m_szSsptUser, '\0', MAX_STR_SIZE);
  4564. memset(mi.m_szServerIdentifier, '\0', MAX_STR_SIZE);
  4565. memset(mi.m_szInstanceSuffix, '\0', MAX_STR_SIZE);
  4566. memset(mi.m_szInstanceUnrestrictedUser, '\0', MAX_STR_SIZE);
  4567. memset(mi.m_szInstancePassword, '\0', MAX_STR_SIZE);
  4568. memset(mi.m_szInstancePasswordAgain, '\0', MAX_STR_SIZE);
  4569. memset(mi.m_szInstanceHostName, '\0', MAX_STR_SIZE);
  4570. memset(mi.m_szSupplierDN, '\0', MAX_STR_SIZE);
  4571. memset(mi.m_szSupplierPW, '\0', MAX_STR_SIZE);
  4572. memset(mi.m_szSupplierPWAgain, '\0', MAX_STR_SIZE);
  4573. memset(mi.m_szSSLClients, '\0', MAX_STR_SIZE);
  4574. memset(mi.m_szChangeLogDbDir, '\0', MAX_STR_SIZE);
  4575. memset(mi.m_szChangeLogSuffix, '\0', MAX_STR_SIZE);
  4576. memset(mi.m_szConsumerDN, '\0', MAX_STR_SIZE);
  4577. memset(mi.m_szConsumerPW, '\0', MAX_STR_SIZE);
  4578. memset(mi.m_szConsumerPWAgain, '\0', MAX_STR_SIZE);
  4579. memset(mi.m_szConsumerHost, '\0', MAX_STR_SIZE);
  4580. memset(mi.m_szConsumerRoot, '\0', MAX_STR_SIZE);
  4581. memset(mi.m_szConsumerBindAs, '\0', MAX_STR_SIZE);
  4582. memset(mi.m_szConsumerPw, '\0', MAX_STR_SIZE);
  4583. memset(mi.m_szSupplierHost, '\0', MAX_STR_SIZE);
  4584. memset(mi.m_szSupplierRoot, '\0', MAX_STR_SIZE);
  4585. memset(mi.m_szSupplierBindAs, '\0', MAX_STR_SIZE);
  4586. memset(mi.m_szSupplierPw, '\0', MAX_STR_SIZE);
  4587. memset(mi.m_szPopLdifFile, '\0', MAX_STR_SIZE);
  4588. memset(mi.m_szCIRDays, '\0', N_DAYS);
  4589. memset(mi.m_szCIRTimes, '\0', N_TIMES);
  4590. memset(mi.m_szSIRDays, '\0', N_DAYS);
  4591. memset(mi.m_szSIRTimes, '\0', N_TIMES);
  4592. }
  4593. //////////////////////////////////////////////////////////////////////////////
  4594. //getSNMPStatus()
  4595. //
  4596. // sets module info for state of SNMPService
  4597. // if its on asks user if ok to turn it off
  4598. // if user says no or there is an error it returns false
  4599. //
  4600. BOOL getSNMPStatus()
  4601. {
  4602. BOOL bReturn = TRUE;
  4603. if ( TRUE == isServiceRunning(SNMP_SERVICE) )
  4604. {
  4605. // its running
  4606. if (SILENTMODE == MODE)
  4607. {
  4608. /* don't prompt user, jsut turn it off */
  4609. if ( 0 == ControlServer(SNMP_SERVICE, FALSE) )
  4610. {
  4611. DSMessageBoxOK(ERR_SNMP_BAD_SHUTDOWN_TITLE,
  4612. ERR_SNMP_BAD_SHUTDOWN, 0);
  4613. bReturn = FALSE;
  4614. }
  4615. mi.m_nSNMPOn = 1;
  4616. } else
  4617. {
  4618. /* ask the user what they want to do */
  4619. if ( IDOK == DSMessageBox(MB_OKCANCEL, ERR_SNMP_IS_RUNNING_TITLE,
  4620. ERR_SNMP_IS_RUNNING, 0) )
  4621. {
  4622. /* save state for later use by cache so we know what to do in post install */
  4623. mi.m_nSNMPOn = 1;
  4624. if ( 0 == ControlServer(SNMP_SERVICE, FALSE) )
  4625. {
  4626. DSMessageBoxOK(ERR_SNMP_BAD_SHUTDOWN_TITLE,
  4627. ERR_SNMP_BAD_SHUTDOWN, 0);
  4628. bReturn = FALSE;
  4629. }
  4630. } else
  4631. {
  4632. UINT uExitCode = 1;
  4633. /* stevross: use ExitProcess until admin server provides us with
  4634. better way to exit framework and cleanup */
  4635. ExitProcess(uExitCode);
  4636. }
  4637. }
  4638. } else
  4639. {
  4640. mi.m_nSNMPOn = 0;
  4641. }
  4642. return bReturn;
  4643. }
  4644. /////////////////////////////////////////////////////////////////
  4645. //
  4646. // somehow determine if slapd is installed under this server root
  4647. //
  4648. //
  4649. BOOL slapdExists(char *pszServerRoot)
  4650. {
  4651. BOOL bReturn = FALSE;
  4652. WIN32_FIND_DATA fileData;
  4653. HANDLE hFileHandle;
  4654. CHAR szCurrentDir[MAX_STR_SIZE]="\0";
  4655. /* not sure what the right way to check is, try this for now */
  4656. /* check if any slapd instances exist in server root */
  4657. /* later look in directory for anything slapd- */
  4658. /* get current dir so we have it for later */
  4659. GetCurrentDirectory(MAX_STR_SIZE, szCurrentDir);
  4660. /* change current dir to server root */
  4661. SetCurrentDirectory(pszServerRoot);
  4662. hFileHandle = FindFirstFile("slapd-*", &fileData);
  4663. if( INVALID_HANDLE_VALUE != hFileHandle)
  4664. {
  4665. /* found slapd- something */
  4666. bReturn = TRUE;
  4667. }
  4668. /* set back to previous current directory */
  4669. SetCurrentDirectory(szCurrentDir);
  4670. return bReturn;
  4671. }
  4672. /////////////////////////////////////////////////////////////////
  4673. //
  4674. // turn slapd instances in this server root on or off
  4675. //
  4676. //
  4677. BOOL ControlSlapdServers(char *pszServerRoot, BOOL bOn, BOOL fixPwd)
  4678. {
  4679. BOOL bReturn = FALSE;
  4680. WIN32_FIND_DATA fileData;
  4681. HANDLE hFileHandle;
  4682. CHAR szCurrentDir[MAX_STR_SIZE]="\0";
  4683. /* not sure what the right way to check is, try this for now */
  4684. /* check if any slapd instances exist in server root */
  4685. /* later look in directory for anything slapd- */
  4686. /* get current dir so we have it for later */
  4687. GetCurrentDirectory(MAX_STR_SIZE, szCurrentDir);
  4688. /* change current dir to server root */
  4689. SetCurrentDirectory(pszServerRoot);
  4690. hFileHandle = FindFirstFile("slapd-*", &fileData);
  4691. if( INVALID_HANDLE_VALUE != hFileHandle)
  4692. {
  4693. if (fixPwd)
  4694. {
  4695. /* convert password file to new pin format */
  4696. ConvertPasswordToPin(pszServerRoot, fileData.cFileName);
  4697. /* do any server upgrade stuff */
  4698. ReinstallUpgradeServer(pszServerRoot, fileData.cFileName);
  4699. }
  4700. /* turn on server */
  4701. ControlSlapdInstance(fileData.cFileName, bOn);
  4702. while(TRUE == FindNextFile(hFileHandle, &fileData) )
  4703. {
  4704. if (fixPwd)
  4705. {
  4706. /* convert password file to new pin format */
  4707. ConvertPasswordToPin(pszServerRoot, fileData.cFileName);
  4708. /* do any server upgrade stuff */
  4709. ReinstallUpgradeServer(pszServerRoot, fileData.cFileName);
  4710. }
  4711. /* turn on server */
  4712. ControlSlapdInstance(fileData.cFileName, bOn);
  4713. }
  4714. }
  4715. /* wait to make sure give server enough time startup/shutdown*/
  4716. /* this time should be long enough for all instances we just */
  4717. /* tried to shutdown/startup */
  4718. Sleep(SLAPD_SHUTDOWN_TIME_MILLISECONDS);
  4719. /* set back to previous current directory */
  4720. SetCurrentDirectory(szCurrentDir);
  4721. return bReturn;
  4722. }
  4723. //////////////////////////////////////////////////////////////////////////////
  4724. // TMPL_PreInstall
  4725. //
  4726. // This function is called by the installation framework before asking the
  4727. // user any questions. Here you should determine if all of the requisites
  4728. // for installing this component are being met. If this operation succeeds
  4729. // return TRUE, otherwise display an error message and return FALSE to abort
  4730. // installation.
  4731. //
  4732. BOOL __declspec(dllexport)
  4733. DSINST_PreInstall(LPCSTR lpszInstallPath)
  4734. {
  4735. BOOL bReturn = FALSE;
  4736. // TODO: Add code to check for pre-installation requirements.
  4737. if( TRUE == getSNMPStatus() )
  4738. {
  4739. char * szLdapURL = NULL;
  4740. char * szLdapUser = NULL;
  4741. char * szAdminDomain = NULL;
  4742. getDefaultLdapInfo(TARGETDIR, &szLdapURL, &szLdapUser,
  4743. &szAdminDomain);
  4744. if (szLdapURL && szAdminDomain)
  4745. {
  4746. my_strncpy(mi.m_szLdapURL, szLdapURL, sizeof(mi.m_szLdapURL));
  4747. GetURLComponents(mi.m_szLdapURL, mi.m_szMCCHost,
  4748. &mi.m_nMCCPort, mi.m_szMCCSuffix);
  4749. if (mi.m_szMCCSuffix[0] == 0)
  4750. my_strncpy(mi.m_szMCCSuffix, NS_DOMAIN_ROOT, sizeof(mi.m_szMCCSuffix));
  4751. if (szLdapUser && mi.m_szMCCBindAs)
  4752. my_strncpy(mi.m_szMCCBindAs, szLdapUser, sizeof(mi.m_szMCCBindAs));
  4753. my_strncpy(mi.m_szAdminDomain, szAdminDomain, sizeof(mi.m_szAdminDomain));
  4754. // since this server root is already configured to use
  4755. // an existing configuration directory server, we will
  4756. // not allow the user to install another one here, so
  4757. // the directory server created here will be a user
  4758. // directory; we will still need to ask for the admin
  4759. // user password
  4760. mi.m_nExistingMCC = 1;
  4761. mi.m_nExistingUG = 0;
  4762. mi.m_nCfgSspt = 0;
  4763. // it's only a reinstall if there is already a slapd
  4764. // installed in this server root
  4765. if( slapdExists(TARGETDIR) )
  4766. mi.m_nReInstall = 1;
  4767. else
  4768. mi.m_nReInstall = 0;
  4769. }
  4770. bReturn = TRUE;
  4771. }
  4772. if (mi.m_nReInstall) {
  4773. char infFile[MAX_PATH] = {0};
  4774. my_snprintf(infFile, sizeof(infFile), "%s\\setup\\slapd\\slapd.inf", TARGETDIR);
  4775. GetProductInfoStringWithTok(SETUP_INF_VERSION, "=", oldVersion,
  4776. OLD_VERSION_SIZE, infFile);
  4777. myLogData("file %s old version is %s", infFile, oldVersion);
  4778. }
  4779. return bReturn;
  4780. }
  4781. //////////////////////////////////////////////////////////////////////////////
  4782. // DSINST_AskOptions
  4783. //
  4784. // This function is called by the installation framework to query the user for
  4785. // information about your component. Here you should ask all of the questions
  4786. // required to install your component as a series of wizard property sheets.
  4787. //
  4788. INT __declspec(dllexport)
  4789. DSINST_AskOptions(HWND hwndParent, INT nDirection)
  4790. {
  4791. PROPSHEETPAGE psp[NUM_PROP_PAGES];
  4792. UINT uStartPage;
  4793. INT nNumPages = 0;
  4794. static INT wasExistingMCC = -1;
  4795. // TODO: Initialize a property page for each dialog template/resource
  4796. // required to query the user for options related to your server
  4797. // installation. Don't forget to increment the count of pages contained
  4798. // in NUM_PROP_PAGES at the top of this file.
  4799. /* Keep the value of mi.m_nExistingMCC at the first invocation */
  4800. if (wasExistingMCC == -1)
  4801. {
  4802. wasExistingMCC = mi.m_nExistingMCC;
  4803. }
  4804. /* if in silent mode or reinstalling, don't display any property pages */
  4805. if ( SILENTMODE == MODE )
  4806. {
  4807. mi.m_nResult = nDirection; // keep moving in same direction...
  4808. }else
  4809. {
  4810. if(1 == mi.m_nReInstall)
  4811. {
  4812. uStartPage = ((nDirection == NS_WIZNEXT) ? 0 : 0);
  4813. AddWizardPage(mi.m_hModule, &psp[0], IDD_REINSTALL_CONFIG, ReInstall_DialogProc);
  4814. nNumPages = 1;
  4815. }else{
  4816. if (EXPRESSMODE == MODE)
  4817. {
  4818. /* just ask for Suitespot ID and Unrestricted User */
  4819. uStartPage = ((nDirection == NS_WIZNEXT) ? 0 : 1);
  4820. if (mi.m_nExistingMCC) // just need admin id and pwd
  4821. AddWizardPage(mi.m_hModule, &psp[0], IDD_ADMIN_ID_ONLY,
  4822. Admin_ID_Only_DialogProc);
  4823. else
  4824. AddWizardPage(mi.m_hModule, &psp[0], IDD_SUITESPOTID,
  4825. SuitespotID_DialogProc);
  4826. AddWizardPage(mi.m_hModule, &psp[1], IDD_ROOTDN, RootDN_DialogProc);
  4827. /* make sure to set numprop pages to actual number */
  4828. nNumPages = 2;
  4829. } else if ( (NORMALMODE == MODE) || (CUSTOMMODE == MODE) )
  4830. {
  4831. /* ask for server settings, SuitespotID and Unrestricted User */
  4832. if ((NORMALMODE == MODE) && wasExistingMCC)
  4833. {
  4834. AddWizardPage(mi.m_hModule, &psp[nNumPages++],
  4835. IDD_SERVER_SETTINGS, Server_Settings_DialogProc);
  4836. AddWizardPage(mi.m_hModule, &psp[nNumPages++],
  4837. IDD_ADMIN_ID_ONLY, Admin_ID_Only_DialogProc);
  4838. AddWizardPage(mi.m_hModule, &psp[nNumPages++],
  4839. IDD_ROOTDN, RootDN_DialogProc);
  4840. }
  4841. else
  4842. {
  4843. AddWizardPage(mi.m_hModule, &psp[nNumPages++],
  4844. IDD_MCC_SETTINGS, MCC_Settings_DialogProc);
  4845. AddWizardPage(mi.m_hModule, &psp[nNumPages++],
  4846. IDD_ADMIN_DOMAIN, AdminDomainCustom_DialogProc);
  4847. AddWizardPage(mi.m_hModule, &psp[nNumPages++],
  4848. IDD_MCC_SETTINGS, UG_Settings_DialogProc);
  4849. AddWizardPage(mi.m_hModule, &psp[nNumPages++],
  4850. IDD_SERVER_SETTINGS, Server_Settings_DialogProc);
  4851. AddWizardPage(mi.m_hModule, &psp[nNumPages++],
  4852. IDD_SUITESPOTID, SuitespotID_DialogProc);
  4853. AddWizardPage(mi.m_hModule, &psp[nNumPages++],
  4854. IDD_ADMIN_DOMAIN, AdminDomain_DialogProc);
  4855. AddWizardPage(mi.m_hModule, &psp[nNumPages++],
  4856. IDD_ROOTDN, RootDN_DialogProc);
  4857. }
  4858. /* add additional pages for custom mode */
  4859. if ( (CUSTOMMODE == MODE) )
  4860. {
  4861. #ifdef CUSTOM_REPL_FOR_4X
  4862. AddWizardPage(mi.m_hModule, &psp[nNumPages++],
  4863. IDD_CHOOSE_REPLICATION_SETUP,
  4864. Choose_Replication_DialogProc);
  4865. AddWizardPage(mi.m_hModule, &psp[nNumPages++],
  4866. IDD_SUPPLIER_REPLICATION_SETTINGS,
  4867. Supplier_Replication_DialogProc);
  4868. AddWizardPage(mi.m_hModule, &psp[nNumPages++],
  4869. IDD_CONSUMER_DN, Consumer_DN_DialogProc);
  4870. AddWizardPage(mi.m_hModule, &psp[nNumPages++],
  4871. IDD_REPLICATION_AGREEMENT,
  4872. Supplier_Replication_Agreement_DialogProc);
  4873. AddWizardPage(mi.m_hModule, &psp[nNumPages++],
  4874. IDD_CONSUMER_REPLICATION_SETTINGS,
  4875. Consumer_Replication_DialogProc);
  4876. AddWizardPage(mi.m_hModule, &psp[nNumPages++],
  4877. IDD_REPLICATION_AGREEMENT,
  4878. Consumer_Replication_Agreement_DialogProc);
  4879. #endif
  4880. AddWizardPage(mi.m_hModule, &psp[nNumPages++],
  4881. IDD_SAMPLE_ENTRIES_ORG,
  4882. Sample_Entries_Org_DialogProc);
  4883. AddWizardPage(mi.m_hModule, &psp[nNumPages++],
  4884. IDD_DISABLE_SCHEMA_CHECKING,
  4885. Disable_Schema_Checking_DialogProc);
  4886. }
  4887. uStartPage = ((nDirection == NS_WIZNEXT) ? 0 : (nNumPages-1));
  4888. }
  4889. }
  4890. // Must initialize the result to an error code before calling WizardDialog
  4891. mi.m_nResult = NS_WIZERROR;
  4892. // Set the first page to display based on the direction we are travelling
  4893. // Call WizardDialog to display the set of property pages
  4894. if (WizardDialog(mi.m_hModule, hwndParent, psp, nNumPages, uStartPage) < 0)
  4895. {
  4896. mi.m_nResult = NS_WIZERROR;
  4897. }
  4898. }
  4899. // convert all DN valued attributes to LDAPv3 quoting
  4900. normalizeDNs();
  4901. // store the User directory information
  4902. storeUserDirectoryInfo();
  4903. if (1 == mi.m_nReInstall)
  4904. {
  4905. set_ldap_settings();
  4906. }
  4907. return mi.m_nResult;
  4908. }
  4909. //////////////////////////////////////////////////////////////////////////////
  4910. // DSINST_GetSummary
  4911. //
  4912. // This function is called by the installation framework after all questions,
  4913. // for all components, have been asked. Here you should provide a detailed
  4914. // summary explaining all of the choices selected by the user.
  4915. //
  4916. // IMPORTANT NOTE: Each line MUST end in a carriage return/line feed
  4917. // combination ("\r\n") as this string is placed in an edit control. Edit
  4918. // controls do not properly handle single "\n" end-of-line characters.
  4919. //
  4920. VOID __declspec(dllexport)
  4921. DSINST_GetSummary(LPSTR lpszSummary)
  4922. {
  4923. // TODO: Add code to fill in the summary information entered by the user
  4924. char *psz = lpszSummary;
  4925. /* only use replication settings written to slapd.conf if dialogs were
  4926. seen by user... otherwise set them to null so posted as null */
  4927. if ( 1 != mi.m_nUseSupplierSettings)
  4928. {
  4929. memset(mi.m_szSupplierDN, '\0', MAX_STR_SIZE);
  4930. }
  4931. if ( 1 != mi.m_nUseChangeLogSettings)
  4932. {
  4933. memset(mi.m_szChangeLogDbDir, '\0', MAX_STR_SIZE);
  4934. memset(mi.m_szChangeLogSuffix, '\0', MAX_STR_SIZE);
  4935. }
  4936. if ( 1 != mi.m_nConfigConsumerDN)
  4937. {
  4938. memset(mi.m_szConsumerDN, '\0', MAX_STR_SIZE);
  4939. }
  4940. /* display in order of dialogs */
  4941. if ( 1 == mi.m_nReInstall )
  4942. {
  4943. psz += WriteSummaryStringRC(psz, " %s\r\n", mi.m_hModule, SUM_REINSTALL, NULL);
  4944. } else
  4945. {
  4946. /* if installing into existing configuration directory display settings entered */
  4947. if ( 1 == mi.m_nExistingMCC)
  4948. {
  4949. psz += WriteSummaryStringRC(psz, " %s\r\n", mi.m_hModule, SUM_CONFIG_DS_TITLE, NULL);
  4950. psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_HOST, mi.m_szMCCHost);
  4951. psz += WriteSummaryIntRC(psz, " %s: %d\r\n", mi.m_hModule, SUM_PORT, mi.m_nMCCPort);
  4952. psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_SUFFIX, mi.m_szMCCSuffix);
  4953. psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_BIND_AS, mi.m_szMCCBindAs);
  4954. }
  4955. /* if storing data in existing directory display options entered */
  4956. if ( 1 == mi.m_nExistingUG)
  4957. {
  4958. psz += WriteSummaryStringRC(psz, " %s\r\n", mi.m_hModule, SUM_DATA_DS_TITLE, NULL);
  4959. psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_HOST, mi.m_szUGHost);
  4960. psz += WriteSummaryIntRC(psz, " %s: %d\r\n", mi.m_hModule, SUM_PORT, mi.m_nUGPort);
  4961. psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_SUFFIX, mi.m_szUGSuffix);
  4962. psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_BIND_AS, mi.m_szUserGroupAdmin);
  4963. }
  4964. /* display instance settings */
  4965. psz += WriteSummaryStringRC(psz, " %s\r\n", mi.m_hModule, SUM_DS_SET_TITLE, NULL);
  4966. psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_SERVER_IDENTIFIER, mi.m_szServerIdentifier);
  4967. psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_SUFFIX, mi.m_szInstanceSuffix);
  4968. psz += WriteSummaryIntRC(psz, " %s: %d\r\n", mi.m_hModule, SUM_PORT, mi.m_nInstanceServerPort);
  4969. if ( 1 != mi.m_nExistingMCC)
  4970. {
  4971. /* if not using Existing MCC display configuration Admin id*/
  4972. /* otherwise it is displayed as the Bind As under Configuration Directory */
  4973. psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_CFG_ADM_ID, mi.m_szSsptUid);
  4974. }
  4975. psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_ADMIN_DOMAIN, mi.m_szAdminDomain);
  4976. psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_DIRECTORY_MANAGER, mi.m_szInstanceUnrestrictedUser);
  4977. /* replication settings */
  4978. if (mi.m_nSetupSupplierReplication != NO_REPLICATION)
  4979. {
  4980. psz += WriteSummaryStringRC(psz, " %s\r\n", mi.m_hModule, SUM_SUPPLIER_REPL_TITLE, NULL);
  4981. /* display changelog DB dir and suffix for both supplier replication modes */
  4982. psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_CHANGELOG_DB_DIR, mi.m_szChangeLogDbDir);
  4983. psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_CHANGELOG_SUFFIX, mi.m_szChangeLogSuffix);
  4984. }
  4985. if (SUPPLIER_SIR_REPLICATION == mi.m_nSetupSupplierReplication)
  4986. {
  4987. /* display replication agreement */
  4988. psz += WriteSummaryStringRC(psz, " %s\r\n", mi.m_hModule, SUM_REPL_AGR_TITLE, NULL);
  4989. psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_HOST, mi.m_szSupplierHost);
  4990. psz += WriteSummaryIntRC(psz, " %s: %d\r\n", mi.m_hModule, SUM_PORT, mi.m_nSupplierPort);
  4991. psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_REPL_ROOT, mi.m_szSupplierRoot);
  4992. psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_BIND_AS, mi.m_szSupplierBindAs);
  4993. psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_REPL_DAYS, mi.m_szSIRDays);
  4994. psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_REPL_TIMES, mi.m_szSIRTimes);
  4995. }
  4996. if (SUPPLIER_CIR_REPLICATION == mi.m_nSetupSupplierReplication )
  4997. {
  4998. /* if configuring consumer BIND DN display what user entered */
  4999. if (1 == mi.m_nConfigConsumerDN)
  5000. {
  5001. psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_CONSUMER_BIND_DN, mi.m_szConsumerDN);
  5002. }
  5003. }
  5004. if (CONSUMER_SIR_REPLICATION == mi.m_nSetupConsumerReplication)
  5005. {
  5006. psz += WriteSummaryStringRC(psz, " %s\r\n", mi.m_hModule, SUM_CONSUMER_REPL_TITLE, NULL);
  5007. /* display supplier bind dn */
  5008. psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_SUPPLIER_DN, mi.m_szSupplierDN);
  5009. }
  5010. if (CONSUMER_CIR_REPLICATION == mi.m_nSetupConsumerReplication)
  5011. {
  5012. psz += WriteSummaryStringRC(psz, " %s\r\n", mi.m_hModule, SUM_CONSUMER_REPL_TITLE, NULL);
  5013. /* display replication agreement */
  5014. /* display replication agreement */
  5015. psz += WriteSummaryStringRC(psz, " %s\r\n", mi.m_hModule, SUM_REPL_AGR_TITLE, NULL);
  5016. psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_HOST, mi.m_szConsumerHost);
  5017. psz += WriteSummaryIntRC(psz, " %s: %d\r\n", mi.m_hModule, SUM_PORT, mi.m_nConsumerPort);
  5018. psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_REPL_ROOT, mi.m_szConsumerRoot);
  5019. psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_BIND_AS, mi.m_szConsumerBindAs);
  5020. psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_REPL_DAYS, mi.m_szCIRDays);
  5021. psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_REPL_TIMES, mi.m_szCIRTimes);
  5022. psz += WriteSummaryIntRC(psz, " %s: %d\r\n", mi.m_hModule, SUM_REPL_SYNC_INTERVAL, mi.m_nCIRInterval);
  5023. }
  5024. if ( CUSTOMMODE == MODE)
  5025. {
  5026. /* display org & ldif files */
  5027. psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_POP_ORG_STRUCT, onezero2yesno(mi.m_nPopulateSampleOrg) );
  5028. psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_POP_DB_FILE, mi.m_szPopLdifFile);
  5029. psz += WriteSummaryStringRC(psz, " %s: %s\r\n", mi.m_hModule, SUM_DISABLE_SCHEMA_CHECKING, onezero2yesno(mi.m_nDisableSchemaChecking) );
  5030. }
  5031. }
  5032. *psz = '\0';
  5033. }
  5034. //////////////////////////////////////////////////////////////////////////////
  5035. // DSINST_WriteGlobalCache
  5036. //
  5037. // This function is called by the installation framework when the user clicks
  5038. // Next at the summary screen. Here you should write all information entered
  5039. // by the user into the installation cache for use during silent installation.
  5040. // Data written to this section of the file may be interpreted by the
  5041. // framework. If this operation succeeds return TRUE, otherwise display an
  5042. // error message and return FALSE to indicate an error.
  5043. //
  5044. BOOL __declspec(dllexport)
  5045. DSINST_WriteGlobalCache(LPCSTR lpszCacheFileName, LPCSTR lpszSectionName)
  5046. {
  5047. if(1 == mi.m_nReInstall)
  5048. {
  5049. /* write configuration directory info, thats the only thing we know about */
  5050. /* during reinstall */
  5051. WritePrivateProfileString(lpszSectionName, GLOBAL_INF_LDAP_USER, mi.m_szMCCBindAs,
  5052. lpszCacheFileName);
  5053. WritePrivateProfileString(lpszSectionName, GLOBAL_INF_LDAP_PASSWD, mi.m_szMCCPw,
  5054. lpszCacheFileName);
  5055. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_K_LDAP_URL, mi.m_szLdapURL,
  5056. lpszCacheFileName);
  5057. /* where do we get admin domain from on ReInstall ??? is default ok? */
  5058. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_ADMIN_DOMAIN, mi.m_szAdminDomain,
  5059. lpszCacheFileName);
  5060. /* shut down all slapd servers so no file conflicts*/
  5061. ControlSlapdServers(TARGETDIR, FALSE, FALSE);
  5062. return TRUE;
  5063. }
  5064. /* this is the first thing called after last dialog, setup UG stuff here if creating UG directory */
  5065. /* stevross: is there a better place to put this ? possibly in GetSummary, */
  5066. /* but what happens in silent mode ?*/
  5067. /* construct the LDAPURL */
  5068. /* suffix must always be o=netscape root */
  5069. my_snprintf(mi.m_szLdapURL, sizeof(mi.m_szLdapURL), "ldap://%s:%d/%s", mi.m_szMCCHost, mi.m_nMCCPort, NS_DOMAIN_ROOT);
  5070. if(mi.m_nExistingUG == 0)
  5071. {
  5072. /* the user is creating a new UG with this instance */
  5073. /* create ou=People/ou=Groups */
  5074. // mi.m_nPopulateSampleOrg = 1;
  5075. // lstrcpy(mi.m_szPopLdifFile, SUGGEST_LDIF);
  5076. if(mi.m_nExistingMCC == 0)
  5077. {
  5078. /* the user is also creating a new MCC so set UG admin to MCC admin */
  5079. my_strncpy(mi.m_szUserGroupAdmin, mi.m_szMCCBindAs, sizeof(mi.m_szUserGroupAdmin));
  5080. my_strncpy(mi.m_szUserGroupAdminPW, mi.m_szMCCPw, sizeof(mi.m_szUserGroupAdminPW));
  5081. }else{
  5082. /* user is using an existing MCC so only creating UG, make UG user same as
  5083. Root DN */
  5084. my_strncpy(mi.m_szUserGroupAdmin, mi.m_szInstanceUnrestrictedUser, sizeof(mi.m_szUserGroupAdmin));
  5085. my_strncpy(mi.m_szUserGroupAdminPW, mi.m_szInstancePassword, sizeof(mi.m_szUserGroupAdminPW));
  5086. }
  5087. my_snprintf(mi.m_szUserGroupURL, sizeof(mi.m_szUserGroupURL), "ldap://%s:%d/%s", mi.m_szInstanceHostName,
  5088. mi.m_nInstanceServerPort, mi.m_szInstanceSuffix);
  5089. }
  5090. WritePrivateProfileString(lpszSectionName, GLOBAL_INF_LDAP_USER, mi.m_szMCCBindAs,
  5091. lpszCacheFileName);
  5092. WritePrivateProfileString(lpszSectionName, GLOBAL_INF_LDAP_PASSWD, mi.m_szMCCPw,
  5093. lpszCacheFileName);
  5094. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_ADMIN_DOMAIN, mi.m_szAdminDomain,
  5095. lpszCacheFileName);
  5096. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_K_LDAP_URL, mi.m_szLdapURL,
  5097. lpszCacheFileName);
  5098. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_USER_GROUP_LDAP_URL, mi.m_szUserGroupURL,
  5099. lpszCacheFileName);
  5100. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_USER_GROUP_ADMIN_ID, mi.m_szUserGroupAdmin,
  5101. lpszCacheFileName);
  5102. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_USER_GROUP_ADMIN_PWD, mi.m_szUserGroupAdminPW,
  5103. lpszCacheFileName);
  5104. return TRUE;
  5105. }
  5106. //////////////////////////////////////////////////////////////////////////////
  5107. // DSINST_WriteLocalCache
  5108. //
  5109. // This function is called by the installation framework when the user clicks
  5110. // Next at the summary screen. Here you should write all information entered
  5111. // by the user into the installation cache for use during silent installation.
  5112. // Data written to this file is not interpreted by the framework, and may
  5113. // consist of any values that you will need to perform the installation (not
  5114. // just values entered by the user). If this operation succeeds return TRUE,
  5115. // otherwise display an error message and return FALSE to indicate an error.
  5116. //
  5117. BOOL __declspec(dllexport)
  5118. DSINST_WriteLocalCache(LPCSTR lpszCacheFileName, LPCSTR lpszSectionName)
  5119. {
  5120. // TODO: Add code to write data to the cache file (INI format) under the
  5121. // specified section name.
  5122. CHAR szInt[BUFSIZ];
  5123. /* don't want to over write with bogus default values on ReInstall*/
  5124. if(1 == mi.m_nReInstall)
  5125. {
  5126. /* just write snmp status cause thats the only thing we really know*/
  5127. /* will allow to control it on reinstall also */
  5128. WritePrivateProfileString(lpszSectionName, LOCAL_INF_SNMP_ON, onezero2yesno(mi.m_nSNMPOn),
  5129. lpszCacheFileName);
  5130. return TRUE;
  5131. }
  5132. /* general settings */
  5133. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_USE_EXISTING_MC, onezero2yesno(mi.m_nExistingMCC),
  5134. lpszCacheFileName);
  5135. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_USE_EXISTING_UG, onezero2yesno(mi.m_nExistingUG),
  5136. lpszCacheFileName);
  5137. my_snprintf(szInt, sizeof(szInt), "%d", mi.m_nInstanceServerPort);
  5138. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_SERVER_PORT, szInt,
  5139. lpszCacheFileName);
  5140. if(!mi.m_nExistingUG)
  5141. {
  5142. /* don't write this key when config only directory */
  5143. /* config only directory when using existing data store */
  5144. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_SUFFIX, mi.m_szInstanceSuffix,
  5145. lpszCacheFileName);
  5146. }
  5147. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_ROOTDN, mi.m_szInstanceUnrestrictedUser,
  5148. lpszCacheFileName);
  5149. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_ROOTDNPWD, mi.m_szInstancePassword,
  5150. lpszCacheFileName);
  5151. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_SERVER_IDENTIFIER, mi.m_szServerIdentifier,
  5152. lpszCacheFileName);
  5153. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_SLAPD_CONFIG_FOR_MC, onezero2yesno(mi.m_nCfgSspt),
  5154. lpszCacheFileName);
  5155. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_ADD_SAMPLE_ENTRIES,
  5156. onezero2yesno(mi.m_nPopulateSampleEntries),
  5157. lpszCacheFileName);
  5158. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_ADD_ORG_ENTRIES, onezero2yesno(mi.m_nPopulateSampleOrg),
  5159. lpszCacheFileName);
  5160. my_snprintf(szInt, sizeof(szInt), "%s", onezero2yesno( ( (NO_REPLICATION != mi.m_nSetupConsumerReplication) || (NO_REPLICATION != mi.m_nSetupSupplierReplication) ) ) );
  5161. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_USE_REPLICATION, szInt,
  5162. lpszCacheFileName);
  5163. /* consumer replication settings */
  5164. /* write no instead of number for no replication to be like unix installer */
  5165. if(NO_REPLICATION != mi.m_nSetupConsumerReplication)
  5166. {
  5167. my_snprintf(szInt, sizeof(szInt), "%d", mi.m_nSetupConsumerReplication);
  5168. }else{
  5169. my_snprintf(szInt, sizeof(szInt), "no");
  5170. }
  5171. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_SETUP_CONSUMER, szInt,
  5172. lpszCacheFileName);
  5173. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_CIR_HOST, mi.m_szConsumerHost,
  5174. lpszCacheFileName);
  5175. my_snprintf(szInt, sizeof(szInt), "%d", mi.m_nConsumerPort );
  5176. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_CIR_PORT, szInt,
  5177. lpszCacheFileName);
  5178. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_CIR_SUFFIX, mi.m_szConsumerRoot,
  5179. lpszCacheFileName);
  5180. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_CIR_BINDDN, mi.m_szConsumerBindAs,
  5181. lpszCacheFileName);
  5182. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_CIR_BINDDNPWD, mi.m_szConsumerPw,
  5183. lpszCacheFileName);
  5184. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_CIR_SECURITY_ON, onezero2yesno(mi.m_nConsumerSSL),
  5185. lpszCacheFileName);
  5186. my_snprintf(szInt, sizeof(szInt), "%d", mi.m_nCIRInterval );
  5187. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_CIR_INTERVAL, szInt,
  5188. lpszCacheFileName);
  5189. if(!strcmp(DEFAULT_CIR_DAYS, mi.m_szCIRDays) )
  5190. {
  5191. /* if default of all days write null to inf file as that is what cgi wants */
  5192. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_CIR_DAYS, "\0",
  5193. lpszCacheFileName);
  5194. }else{
  5195. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_CIR_DAYS, mi.m_szCIRDays,
  5196. lpszCacheFileName);
  5197. }
  5198. if(!strcmp(DEFAULT_CIR_TIMES, mi.m_szCIRTimes) )
  5199. {
  5200. /* if default of all times write null to inf file as that is what cgi wants */
  5201. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_CIR_TIMES, "\0",
  5202. lpszCacheFileName);
  5203. }else{
  5204. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_CIR_TIMES, mi.m_szCIRTimes,
  5205. lpszCacheFileName);
  5206. }
  5207. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_REPLICATIONDN, mi.m_szSupplierDN,
  5208. lpszCacheFileName);
  5209. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_REPLICATIONPWD, mi.m_szSupplierPW,
  5210. lpszCacheFileName);
  5211. /* Supplier replication settings */
  5212. /* write no instead of number for no replication to be like unix installer */
  5213. if(NO_REPLICATION != mi.m_nSetupSupplierReplication)
  5214. {
  5215. my_snprintf(szInt, sizeof(szInt), "%d", mi.m_nSetupSupplierReplication);
  5216. }else{
  5217. my_snprintf(szInt, sizeof(szInt), "no");
  5218. }
  5219. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_SETUP_SUPPLIER, szInt,
  5220. lpszCacheFileName);
  5221. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_CHANGELOGDIR, mi.m_szChangeLogDbDir,
  5222. lpszCacheFileName);
  5223. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_CHANGELOGSUFFIX, mi.m_szChangeLogSuffix,
  5224. lpszCacheFileName);
  5225. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_SIR_HOST, mi.m_szSupplierHost,
  5226. lpszCacheFileName);
  5227. my_snprintf(szInt, sizeof(szInt), "%d", mi.m_nSupplierPort );
  5228. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_SIR_PORT, szInt,
  5229. lpszCacheFileName);
  5230. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_SIR_SUFFIX, mi.m_szSupplierRoot,
  5231. lpszCacheFileName);
  5232. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_SIR_BINDDN, mi.m_szSupplierBindAs,
  5233. lpszCacheFileName);
  5234. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_SIR_BINDDNPWD, mi.m_szSupplierPw,
  5235. lpszCacheFileName);
  5236. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_SIR_SECURITY_ON, onezero2yesno( mi.m_nSupplierSSL),
  5237. lpszCacheFileName);
  5238. if(!strcmp(DEFAULT_SIR_DAYS, mi.m_szSIRDays) )
  5239. {
  5240. /* if default of all days write null to inf file as that is what cgi wants */
  5241. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_SIR_DAYS, "\0",
  5242. lpszCacheFileName);
  5243. }else{
  5244. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_SIR_DAYS, mi.m_szSIRDays,
  5245. lpszCacheFileName);
  5246. }
  5247. if(!strcmp(DEFAULT_SIR_TIMES, mi.m_szSIRTimes) )
  5248. {
  5249. /* if default of all times write null to inf file as that is what cgi wants */
  5250. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_SIR_TIMES, "\0",
  5251. lpszCacheFileName);
  5252. }else{
  5253. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_SIR_TIMES, mi.m_szSIRTimes,
  5254. lpszCacheFileName);
  5255. }
  5256. WritePrivateProfileString(lpszSectionName, LOCAL_INF_CONFIG_CONSUMER_DN, onezero2yesno(mi.m_nConfigConsumerDN),
  5257. lpszCacheFileName);
  5258. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_CONSUMERDN, mi.m_szConsumerDN,
  5259. lpszCacheFileName);
  5260. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_CONSUMERPWD, mi.m_szConsumerPW,
  5261. lpszCacheFileName);
  5262. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_INSTALL_LDIF_FILE, mi.m_szPopLdifFile,
  5263. lpszCacheFileName);
  5264. WritePrivateProfileString(lpszSectionName, SLAPD_KEY_DISABLE_SCHEMA_CHECKING, onezero2yesno(mi.m_nDisableSchemaChecking),
  5265. lpszCacheFileName);
  5266. WritePrivateProfileString(lpszSectionName, LOCAL_INF_SNMP_ON, onezero2yesno(mi.m_nSNMPOn),
  5267. lpszCacheFileName);
  5268. return TRUE;
  5269. }
  5270. //////////////////////////////////////////////////////////////////////////////
  5271. // DSINST_ReadGlobalCache
  5272. //
  5273. // This function is called by the installation framework during silent install
  5274. // to initialize your data from the cache file you created above. Here you
  5275. // should read any information stored in the installation cache's global
  5276. // section that you need. If this operation succeeds return TRUE, otherwise
  5277. // display an error message and return FALSE to indicate an error.
  5278. //
  5279. BOOL __declspec(dllexport)
  5280. DSINST_ReadGlobalCache(LPCSTR lpszCacheFileName, LPCSTR lpszSectionName)
  5281. {
  5282. // TODO: Add code to read data from the cache file (INI format) under the
  5283. // specified section name.
  5284. /* stevross: this may be null when reading cache for post install or something, so
  5285. make sure to allocate it again */
  5286. CHAR szFormat[MAX_STR_SIZE];
  5287. if(1 == mi.m_nReInstall)
  5288. {
  5289. /* just read config directory stuff */
  5290. /* this is the only stuff we are need and are guaranteed to have */
  5291. LoadString( mi.m_hModule, ERR_READ_GLOBAL_CACHE, szFormat, MAX_STR_SIZE);
  5292. GetPrivateProfileString(lpszSectionName, SLAPD_KEY_FULL_MACHINE_NAME, "\0",
  5293. mi.m_szInstanceHostName, MAX_STR_SIZE,
  5294. lpszCacheFileName);
  5295. if (mi.m_szInstanceHostName[0] == 0)
  5296. DSGetHostName(mi.m_szInstanceHostName, MAX_STR_SIZE);
  5297. if(NULL == mi.m_szMCCBindAs )
  5298. {
  5299. mi.m_szMCCBindAs = malloc(MAX_STR_SIZE);
  5300. }
  5301. GetPrivateProfileString(lpszSectionName, GLOBAL_INF_LDAP_USER, "\0",
  5302. mi.m_szMCCBindAs, MAX_STR_SIZE,
  5303. lpszCacheFileName);
  5304. if ( 0 == lstrcmp(mi.m_szMCCBindAs, "\0") )
  5305. {
  5306. DSMessageBoxOK(ERR_NO_SS_ADMIN_TITLE, ERR_NO_SS_ADMIN, 0);
  5307. return FALSE;
  5308. }else{
  5309. /* stevross: now that cgi can handle full DN
  5310. Sspt UID is same user as MCC BindAs no matter what
  5311. look into removing later once get instance creatin working */
  5312. my_strncpy(mi.m_szSsptUid, mi.m_szMCCBindAs, sizeof(mi.m_szSsptUid));
  5313. }
  5314. GetPrivateProfileString(lpszSectionName, GLOBAL_INF_LDAP_PASSWD, "\0",
  5315. mi.m_szMCCPw, MAX_STR_SIZE,
  5316. lpszCacheFileName);
  5317. if ( 0 == lstrcmp(mi.m_szMCCPw, "\0") )
  5318. {
  5319. DSMessageBoxOK(ERR_NO_PW_TITLE, ERR_NO_PW, 0);
  5320. return FALSE;
  5321. }else{
  5322. /* use password for sspt user since this is the ssptuser */
  5323. my_strncpy(mi.m_szSsptUidPw, mi.m_szMCCPw, sizeof(mi.m_szSsptUidPw));
  5324. my_strncpy(mi.m_szSsptUidPwAgain, mi.m_szSsptUidPw, sizeof(mi.m_szSsptUidPwAgain));
  5325. }
  5326. GetPrivateProfileString(lpszSectionName, SLAPD_KEY_ADMIN_DOMAIN, "\0",
  5327. mi.m_szAdminDomain, MAX_STR_SIZE,
  5328. lpszCacheFileName);
  5329. GetPrivateProfileString(lpszSectionName, SLAPD_KEY_K_LDAP_URL, "\0",
  5330. mi.m_szLdapURL, MAX_STR_SIZE,
  5331. lpszCacheFileName);
  5332. if( GetURLComponents(mi.m_szLdapURL, mi.m_szMCCHost,
  5333. &mi.m_nMCCPort, mi.m_szMCCSuffix) != 0)
  5334. {
  5335. DSMessageBoxOK(ERR_NO_CONFIG_URL_TITLE, ERR_NO_CONFIG_URL, 0);
  5336. return FALSE;
  5337. }
  5338. return TRUE;
  5339. }
  5340. LoadString( mi.m_hModule, ERR_READ_GLOBAL_CACHE, szFormat, MAX_STR_SIZE);
  5341. GetPrivateProfileString(lpszSectionName, SLAPD_KEY_FULL_MACHINE_NAME, "\0",
  5342. mi.m_szInstanceHostName, MAX_STR_SIZE,
  5343. lpszCacheFileName);
  5344. if (mi.m_szInstanceHostName[0] == 0)
  5345. DSGetHostName(mi.m_szInstanceHostName, MAX_STR_SIZE);
  5346. if(NULL == mi.m_szMCCBindAs )
  5347. {
  5348. mi.m_szMCCBindAs = malloc(MAX_STR_SIZE);
  5349. }
  5350. GetPrivateProfileString(lpszSectionName, GLOBAL_INF_LDAP_USER, "\0",
  5351. mi.m_szMCCBindAs, MAX_STR_SIZE,
  5352. lpszCacheFileName);
  5353. if ( 0 == lstrcmp(mi.m_szMCCBindAs, "\0") )
  5354. {
  5355. DSMessageBoxOK(ERR_NO_SS_ADMIN_TITLE, ERR_NO_SS_ADMIN, 0);
  5356. return FALSE;
  5357. }else{
  5358. /* stevross: now that cgi can handle full DN
  5359. Sspt UID is same user as MCC BindAs no matter what
  5360. look into removing later once get instance creatin working */
  5361. my_strncpy(mi.m_szSsptUid, mi.m_szMCCBindAs, sizeof(mi.m_szSsptUid));
  5362. }
  5363. GetPrivateProfileString(lpszSectionName, GLOBAL_INF_LDAP_PASSWD, "\0",
  5364. mi.m_szMCCPw, MAX_STR_SIZE,
  5365. lpszCacheFileName);
  5366. if ( 0 == lstrcmp(mi.m_szMCCPw, "\0") )
  5367. {
  5368. DSMessageBoxOK(ERR_NO_PW_TITLE, ERR_NO_PW, 0);
  5369. return FALSE;
  5370. }else{
  5371. /* use password for sspt user since this is the ssptuser */
  5372. my_strncpy(mi.m_szSsptUidPw, mi.m_szMCCPw, sizeof(mi.m_szSsptUidPw));
  5373. my_strncpy(mi.m_szSsptUidPwAgain, mi.m_szSsptUidPw, sizeof(mi.m_szSsptUidPwAgain));
  5374. }
  5375. GetPrivateProfileString(lpszSectionName, SLAPD_KEY_ADMIN_DOMAIN, "\0",
  5376. mi.m_szAdminDomain, MAX_STR_SIZE,
  5377. lpszCacheFileName);
  5378. GetPrivateProfileString(lpszSectionName, SLAPD_KEY_K_LDAP_URL, "\0",
  5379. mi.m_szLdapURL, MAX_STR_SIZE,
  5380. lpszCacheFileName);
  5381. if( GetURLComponents(mi.m_szLdapURL, mi.m_szMCCHost,
  5382. &mi.m_nMCCPort, mi.m_szMCCSuffix) != 0)
  5383. {
  5384. DSMessageBoxOK(ERR_NO_CONFIG_URL_TITLE, ERR_NO_CONFIG_URL, 0);
  5385. return FALSE;
  5386. }
  5387. GetPrivateProfileString(lpszSectionName, SLAPD_KEY_USER_GROUP_LDAP_URL, "\0",
  5388. mi.m_szUserGroupURL, MAX_STR_SIZE,
  5389. lpszCacheFileName);
  5390. if( GetURLComponents(mi.m_szUserGroupURL, mi.m_szUGHost,
  5391. &mi.m_nUGPort, mi.m_szUGSuffix) != 0)
  5392. {
  5393. DSMessageBoxOK(ERR_NO_USER_URL_TITLE, ERR_NO_USER_URL, 0);
  5394. return FALSE;
  5395. }
  5396. GetPrivateProfileString(lpszSectionName, SLAPD_KEY_USER_GROUP_ADMIN_ID, "\0",
  5397. mi.m_szUserGroupAdmin, MAX_STR_SIZE,
  5398. lpszCacheFileName);
  5399. GetPrivateProfileString(lpszSectionName, SLAPD_KEY_USER_GROUP_ADMIN_PWD, "\0",
  5400. mi.m_szUserGroupAdminPW, MAX_STR_SIZE,
  5401. lpszCacheFileName);
  5402. return TRUE;
  5403. }
  5404. //////////////////////////////////////////////////////////////////////////////
  5405. // DSINST_ReadLocalCache
  5406. //
  5407. // This function is called by the installation framework during silent install
  5408. // to intialize your data from the local section of the cache created above.
  5409. // Here you should read any information stored in the installation cache's
  5410. // local section that you need. If this operation succeeds return TRUE,
  5411. // otherwise display an error message and return FALSE to indicate an error.
  5412. //
  5413. BOOL __declspec(dllexport)
  5414. DSINST_ReadLocalCache(LPCSTR lpszCacheFileName, LPCSTR lpszSectionName)
  5415. {
  5416. // TODO: Add code to read data from the cache file (INI format) under the
  5417. // specified section name.
  5418. char szTemp[BUFSIZ];
  5419. CHAR szFormat[MAX_STR_SIZE];
  5420. /* only ting we know on this section during reinstall is SNMP value */
  5421. if(1 == mi.m_nReInstall)
  5422. {
  5423. GetPrivateProfileString(lpszSectionName, LOCAL_INF_SNMP_ON, "\0",
  5424. szTemp, BUFSIZ,
  5425. lpszCacheFileName);
  5426. mi.m_nSNMPOn = yesno2onezero(szTemp);
  5427. return TRUE;
  5428. }
  5429. LoadString( mi.m_hModule, ERR_READ_LOCAL_CACHE, szFormat, MAX_STR_SIZE);
  5430. GetPrivateProfileString(lpszSectionName, SLAPD_KEY_USE_EXISTING_MC, "\0",
  5431. szTemp, BUFSIZ,
  5432. lpszCacheFileName);
  5433. mi.m_nExistingMCC = yesno2onezero(szTemp);
  5434. GetPrivateProfileString(lpszSectionName, SLAPD_KEY_USE_EXISTING_UG, "\0",
  5435. szTemp, BUFSIZ,
  5436. lpszCacheFileName);
  5437. mi.m_nExistingUG = yesno2onezero(szTemp);
  5438. mi.m_nInstanceServerPort = GetPrivateProfileInt(lpszSectionName,
  5439. SLAPD_KEY_SERVER_PORT, DEFAULT_SERVER_PORT, lpszCacheFileName);
  5440. GetPrivateProfileString(lpszSectionName, SLAPD_KEY_SUFFIX, "\0",
  5441. mi.m_szInstanceSuffix, MAX_STR_SIZE,
  5442. lpszCacheFileName);
  5443. GetPrivateProfileString(lpszSectionName, SLAPD_KEY_ROOTDN, "\0",
  5444. mi.m_szInstanceUnrestrictedUser, MAX_STR_SIZE,
  5445. lpszCacheFileName);
  5446. GetPrivateProfileString(lpszSectionName, SLAPD_KEY_ROOTDNPWD, "\0",
  5447. mi.m_szInstancePassword, MAX_STR_SIZE,
  5448. lpszCacheFileName);
  5449. my_strncpy(mi.m_szInstancePasswordAgain, mi.m_szInstancePassword, sizeof(mi.m_szInstancePasswordAgain));
  5450. GetPrivateProfileString(lpszSectionName, SLAPD_KEY_SERVER_IDENTIFIER, "\0",
  5451. mi.m_szServerIdentifier, MAX_STR_SIZE,
  5452. lpszCacheFileName);
  5453. GetPrivateProfileString(lpszSectionName, SLAPD_KEY_SLAPD_CONFIG_FOR_MC, "\0",
  5454. szTemp, BUFSIZ,
  5455. lpszCacheFileName);
  5456. mi.m_nCfgSspt = yesno2onezero(szTemp);
  5457. /*stevross: should I add more error checking below? These are only required in certain cases*/
  5458. GetPrivateProfileString(lpszSectionName, SLAPD_KEY_ADD_SAMPLE_ENTRIES, "\0",
  5459. szTemp, BUFSIZ,
  5460. lpszCacheFileName);
  5461. mi.m_nPopulateSampleEntries = yesno2onezero(szTemp);
  5462. GetPrivateProfileString(lpszSectionName, SLAPD_KEY_ADD_ORG_ENTRIES, "\0",
  5463. szTemp, BUFSIZ,
  5464. lpszCacheFileName);
  5465. mi.m_nPopulateSampleOrg = yesno2onezero(szTemp);
  5466. GetPrivateProfileString(lpszSectionName, SLAPD_KEY_SETUP_CONSUMER, "\0",
  5467. szTemp, BUFSIZ,
  5468. lpszCacheFileName);
  5469. /* value should be no, 1 or 2 to be like unix installer*/
  5470. if(!strcmpi(szTemp, "no") )
  5471. {
  5472. mi.m_nSetupConsumerReplication = NO_REPLICATION;
  5473. }else{
  5474. mi.m_nSetupConsumerReplication = GetPrivateProfileInt(lpszSectionName, SLAPD_KEY_SETUP_CONSUMER,
  5475. DEFAULT_SETUP_CONSUMER, lpszCacheFileName);
  5476. }
  5477. GetPrivateProfileString(lpszSectionName, SLAPD_KEY_CIR_HOST, "\0",
  5478. mi.m_szConsumerHost, MAX_STR_SIZE,
  5479. lpszCacheFileName);
  5480. mi.m_nConsumerPort = GetPrivateProfileInt(lpszSectionName, SLAPD_KEY_CIR_PORT,
  5481. DEFAULT_CIR_PORT, lpszCacheFileName);
  5482. GetPrivateProfileString(lpszSectionName, SLAPD_KEY_CIR_SUFFIX, "\0",
  5483. mi.m_szConsumerRoot, MAX_STR_SIZE,
  5484. lpszCacheFileName);
  5485. GetPrivateProfileString(lpszSectionName, SLAPD_KEY_CIR_BINDDN, "\0",
  5486. mi.m_szConsumerBindAs, MAX_STR_SIZE,
  5487. lpszCacheFileName);
  5488. GetPrivateProfileString(lpszSectionName, SLAPD_KEY_CIR_BINDDNPWD, "\0",
  5489. mi.m_szConsumerPw, MAX_STR_SIZE,
  5490. lpszCacheFileName);
  5491. GetPrivateProfileString(lpszSectionName, SLAPD_KEY_CIR_SECURITY_ON, "\0",
  5492. szTemp, BUFSIZ,
  5493. lpszCacheFileName);
  5494. mi.m_nConsumerSSL = yesno2onezero(szTemp);
  5495. mi.m_nCIRInterval = GetPrivateProfileInt(lpszSectionName, SLAPD_KEY_CIR_INTERVAL,
  5496. DEFAULT_CIR_INTERVAL, lpszCacheFileName);
  5497. GetPrivateProfileString(lpszSectionName, SLAPD_KEY_CIR_DAYS, DEFAULT_CIR_DAYS,
  5498. mi.m_szCIRDays, N_DAYS,
  5499. lpszCacheFileName);
  5500. GetPrivateProfileString(lpszSectionName, SLAPD_KEY_CIR_TIMES, DEFAULT_CIR_TIMES,
  5501. mi.m_szCIRTimes, N_TIMES,
  5502. lpszCacheFileName);
  5503. GetPrivateProfileString(lpszSectionName, SLAPD_KEY_REPLICATIONDN, "\0",
  5504. mi.m_szSupplierDN, MAX_STR_SIZE,
  5505. lpszCacheFileName);
  5506. GetPrivateProfileString(lpszSectionName, SLAPD_KEY_REPLICATIONPWD, "\0",
  5507. mi.m_szSupplierPW, MAX_STR_SIZE,
  5508. lpszCacheFileName);
  5509. /* read from cache, so copy it to mi.m_szSupplierPWAgain); */
  5510. my_strncpy(mi.m_szSupplierPWAgain, mi.m_szSupplierPW, sizeof(mi.m_szSupplierPWAgain));
  5511. /* Supplier replication settings */
  5512. GetPrivateProfileString(lpszSectionName, SLAPD_KEY_SETUP_SUPPLIER, "\0",
  5513. szTemp, BUFSIZ,
  5514. lpszCacheFileName);
  5515. /* value should be no, 1 or 2 to be like unix installer*/
  5516. if(!strcmpi(szTemp, "no"))
  5517. {
  5518. mi.m_nSetupSupplierReplication = NO_REPLICATION;
  5519. }else{
  5520. mi.m_nSetupSupplierReplication = GetPrivateProfileInt(lpszSectionName, SLAPD_KEY_SETUP_SUPPLIER,
  5521. DEFAULT_SETUP_CONSUMER, lpszCacheFileName);
  5522. }
  5523. GetPrivateProfileString(lpszSectionName, SLAPD_KEY_CHANGELOGDIR, "\0",
  5524. mi.m_szChangeLogDbDir, MAX_STR_SIZE,
  5525. lpszCacheFileName);
  5526. GetPrivateProfileString(lpszSectionName, SLAPD_KEY_CHANGELOGSUFFIX, "\0",
  5527. mi.m_szChangeLogSuffix, MAX_STR_SIZE,
  5528. lpszCacheFileName);
  5529. GetPrivateProfileString(lpszSectionName, SLAPD_KEY_SIR_HOST, "\0",
  5530. mi.m_szSupplierHost, MAX_STR_SIZE,
  5531. lpszCacheFileName);
  5532. mi.m_nSupplierPort = GetPrivateProfileInt(lpszSectionName, SLAPD_KEY_SIR_PORT,
  5533. DEFAULT_SIR_PORT, lpszCacheFileName);
  5534. GetPrivateProfileString(lpszSectionName, SLAPD_KEY_SIR_SUFFIX, "\0",
  5535. mi.m_szSupplierRoot, MAX_STR_SIZE,
  5536. lpszCacheFileName);
  5537. GetPrivateProfileString(lpszSectionName, SLAPD_KEY_SIR_BINDDN, "\0",
  5538. mi.m_szSupplierBindAs, MAX_STR_SIZE,
  5539. lpszCacheFileName);
  5540. GetPrivateProfileString(lpszSectionName, SLAPD_KEY_SIR_BINDDNPWD, "\0",
  5541. mi.m_szSupplierPw, MAX_STR_SIZE,
  5542. lpszCacheFileName);
  5543. GetPrivateProfileString(lpszSectionName, SLAPD_KEY_SIR_SECURITY_ON, "\0",
  5544. szTemp, BUFSIZ,
  5545. lpszCacheFileName);
  5546. mi.m_nSupplierSSL = yesno2onezero(szTemp);
  5547. GetPrivateProfileString(lpszSectionName, SLAPD_KEY_SIR_DAYS,DEFAULT_SIR_DAYS,
  5548. mi.m_szSIRDays, N_DAYS,
  5549. lpszCacheFileName);
  5550. GetPrivateProfileString(lpszSectionName, SLAPD_KEY_SIR_TIMES, DEFAULT_SIR_TIMES,
  5551. mi.m_szSIRTimes, N_TIMES,
  5552. lpszCacheFileName);
  5553. GetPrivateProfileString(lpszSectionName, LOCAL_INF_CONFIG_CONSUMER_DN, "\0",
  5554. szTemp, BUFSIZ,
  5555. lpszCacheFileName);
  5556. mi.m_nConfigConsumerDN = yesno2onezero(szTemp);
  5557. GetPrivateProfileString(lpszSectionName, SLAPD_KEY_CONSUMERDN, "\0",
  5558. mi.m_szConsumerDN, MAX_STR_SIZE,
  5559. lpszCacheFileName);
  5560. GetPrivateProfileString(lpszSectionName, SLAPD_KEY_CONSUMERPWD, "\0",
  5561. mi.m_szConsumerPW, MAX_STR_SIZE,
  5562. lpszCacheFileName);
  5563. my_strncpy(mi.m_szConsumerPWAgain, mi.m_szConsumerPW, sizeof(mi.m_szConsumerPWAgain));
  5564. GetPrivateProfileString(lpszSectionName, SLAPD_KEY_INSTALL_LDIF_FILE, DEFAULT_INF_POP_LDIF_FILE,
  5565. mi.m_szPopLdifFile, MAX_STR_SIZE,
  5566. lpszCacheFileName);
  5567. GetPrivateProfileString(lpszSectionName, SLAPD_KEY_DISABLE_SCHEMA_CHECKING, "\0",
  5568. szTemp, BUFSIZ,
  5569. lpszCacheFileName);
  5570. mi.m_nDisableSchemaChecking = yesno2onezero(szTemp);
  5571. GetPrivateProfileString(lpszSectionName, LOCAL_INF_SNMP_ON, "\0",
  5572. szTemp, BUFSIZ,
  5573. lpszCacheFileName);
  5574. mi.m_nSNMPOn = yesno2onezero(szTemp);
  5575. if ( SILENTMODE == MODE)
  5576. {
  5577. /* verify settings here as they didn't get verified in dialog */
  5578. /* stop install if find something bad */
  5579. /* things that always need to be checked */
  5580. if ( Verify_Server_Settings() )
  5581. {
  5582. /* error in server settings */
  5583. return FALSE;
  5584. }
  5585. if ( Verify_ROOTDN() )
  5586. {
  5587. return FALSE;
  5588. }
  5589. #ifdef CUSTOM_REPL_FOR_4X
  5590. if (SUPPLIER_SIR_REPLICATION == mi.m_nSetupSupplierReplication)
  5591. {
  5592. /* always need to check changelogdb and suffix */
  5593. if ( Verify_Supplier_Replication() )
  5594. {
  5595. return FALSE;
  5596. }
  5597. /* check replication agreement */
  5598. if ( VerifyReplAgreement(mi.m_szSupplierHost,
  5599. &mi.m_nSupplierPort,
  5600. mi.m_szSupplierRoot,
  5601. mi.m_szSupplierBindAs,
  5602. mi.m_szSupplierPw,
  5603. mi.m_szSIRDays,
  5604. mi.m_szSIRTimes) )
  5605. {
  5606. return FALSE;
  5607. }
  5608. }
  5609. if (SUPPLIER_CIR_REPLICATION == mi.m_nSetupSupplierReplication)
  5610. {
  5611. /* always need to check changelogdb and suffix */
  5612. if ( Verify_Supplier_Replication() )
  5613. {
  5614. return FALSE;
  5615. }
  5616. if ( Verify_Consumer_DN() )
  5617. {
  5618. return FALSE;
  5619. }
  5620. }
  5621. if (CONSUMER_SIR_REPLICATION == mi.m_nSetupConsumerReplication)
  5622. {
  5623. if ( Verify_Consumer_Replication() )
  5624. {
  5625. return FALSE;
  5626. }
  5627. }
  5628. if (CONSUMER_CIR_REPLICATION == mi.m_nSetupConsumerReplication)
  5629. {
  5630. if ( VerifyReplAgreement(mi.m_szConsumerHost,
  5631. &mi.m_nConsumerPort,
  5632. mi.m_szConsumerRoot,
  5633. mi.m_szConsumerBindAs,
  5634. mi.m_szConsumerPw,
  5635. mi.m_szCIRDays,
  5636. mi.m_szCIRTimes) )
  5637. {
  5638. return FALSE;
  5639. }
  5640. }
  5641. #endif
  5642. }
  5643. /* set ldap settings for silent install mode */
  5644. if(1 != mi.m_nReInstall)
  5645. {
  5646. set_ldap_settings();
  5647. }
  5648. return TRUE;
  5649. }
  5650. //////////////////////////////////////////////////////////////////////////////
  5651. // DSINST_ReadComponentInf
  5652. //
  5653. //
  5654. BOOL __declspec(dllexport) DSINST_ReadComponentInf(LPCSTR pszCacheFile, LPCSTR pszSection)
  5655. {
  5656. char szValue[MAX_PATH];
  5657. myLogData("In DSINST_ReadComponentInf: file [%s] section [%s]",
  5658. pszCacheFile, pszSection);
  5659. GetPrivateProfileString(pszSection, SETUP_INF_COM_VENDOR, "", szValue, sizeof(szValue), pszCacheFile);
  5660. cd.szVendor = _strdup(szValue);
  5661. GetPrivateProfileString(pszSection, SETUP_INF_COM_DESC, "", szValue, sizeof(szValue), pszCacheFile);
  5662. cd.szDescription = _strdup(szValue);
  5663. GetPrivateProfileString(pszSection, SETUP_INF_COM_NAME, "", szValue, sizeof(szValue), pszCacheFile);
  5664. cd.szName = _strdup(szValue);
  5665. GetPrivateProfileString(pszSection, SETUP_INF_COM_NICKNAME, "", szValue, sizeof(szValue), pszCacheFile);
  5666. cd.szNickname = _strdup(szValue);
  5667. GetPrivateProfileString(pszSection, SETUP_INF_COM_VERSION, "", szValue, sizeof(szValue), pszCacheFile);
  5668. cd.szVersion = _strdup(szValue);
  5669. GetPrivateProfileString(pszSection, SETUP_INF_COM_BUILDNUMBER, "", szValue, sizeof(szValue), pszCacheFile);
  5670. cd.szBuildNumber = _strdup(szValue);
  5671. GetPrivateProfileString(pszSection, SETUP_INF_COM_REVISION, "", szValue, sizeof(szValue), pszCacheFile);
  5672. cd.szRevision = _strdup(szValue);
  5673. GetPrivateProfileString(pszSection, SETUP_INF_COM_EXPIRY, "", szValue, sizeof(szValue), pszCacheFile);
  5674. cd.szExpireDate = _strdup(szValue);
  5675. GetPrivateProfileString(pszSection, SETUP_INF_COM_SECURITY, "", szValue, sizeof(szValue), pszCacheFile);
  5676. cd.szSecurity = _strdup(szValue);
  5677. cd.szTimeStamp = _strdup(getGMT());
  5678. myLogData("In DSINST_ReadComponentInf: name=%s nick=%s version=%s build=%s "
  5679. "rev=%s time=%s",
  5680. cd.szName, cd.szNickname, cd.szVersion, cd.szBuildNumber, cd.szRevision,
  5681. cd.szTimeStamp);
  5682. return TRUE;
  5683. }
  5684. //////////////////////////////////////////////////////////////////////////////
  5685. // run_cgi
  5686. //
  5687. //
  5688. // runs a cgi
  5689. //
  5690. //
  5691. //
  5692. //
  5693. //
  5694. static int
  5695. run_cgi(const char *serverroot, const char *cgipath, const char *args)
  5696. {
  5697. int status = 0;
  5698. DWORD procResult;
  5699. DWORD dwLastError = 0;
  5700. char prog[MAX_STR_SIZE] = {0};
  5701. char cmdLine[MAX_STR_SIZE] = {0};
  5702. char netsiteRootEnvVar[MAX_STR_SIZE] = {0};
  5703. LPVOID lpMsgBuf;
  5704. my_snprintf(netsiteRootEnvVar, sizeof(netsiteRootEnvVar), "NETSITE_ROOT=%s", serverroot);
  5705. _putenv(netsiteRootEnvVar);
  5706. if ( getenv("DEBUG_DSINST") )
  5707. DebugBreak();
  5708. /* everything is set, start the program */
  5709. my_snprintf(prog, sizeof(prog), "%s\\%s", serverroot, cgipath);
  5710. if (!FileExists(prog))
  5711. {
  5712. lpMsgBuf = getLastErrorMessage();
  5713. DSMessageBoxOK(ERR_NO_FIND_INST_PROG_TITLE,
  5714. ERR_NO_FIND_INST_PROG, 0, prog, lpMsgBuf, LOGFILE);
  5715. status = -1;
  5716. myLogData("Error: could not find program %s: %d (%s)", prog, GetLastError(), lpMsgBuf);
  5717. LocalFree( lpMsgBuf );
  5718. }
  5719. else
  5720. {
  5721. my_snprintf(cmdLine, sizeof(cmdLine), "\"%s\" %s", prog, args);
  5722. myLogData("run_cgi: before execution of %s", cmdLine);
  5723. if ( (procResult = _LaunchAndWait(cmdLine, INFINITE)) != 0)
  5724. {
  5725. dwLastError = GetLastError();
  5726. lpMsgBuf = getLastErrorMessage();
  5727. myLogData("Error: could not run %s: %d (%s)", cmdLine, dwLastError, lpMsgBuf);
  5728. if(0 == dwLastError)
  5729. {
  5730. DSMessageBoxOK(ERR_EXEC_INST_PROG_TITLE, ERR_UNK_INST_CREATE, 0,
  5731. prog, LOGFILE);
  5732. }else {
  5733. DSMessageBoxOK(ERR_EXEC_INST_PROG_TITLE, ERR_EXEC_INST_PROG, 0,
  5734. prog, lpMsgBuf, LOGFILE);
  5735. }
  5736. LocalFree( lpMsgBuf );
  5737. status = -1;
  5738. }
  5739. myLogData("run_cgi: after execution of %s", cmdLine);
  5740. }
  5741. return status;
  5742. }
  5743. //////////////////////////////////////////////////////////////////////////////
  5744. // create_slapd_instance
  5745. //
  5746. //
  5747. // creates a instance of slapd
  5748. //
  5749. //
  5750. //
  5751. //
  5752. //
  5753. static int
  5754. create_slapd_instance(const char *hostname, const char *serverroot)
  5755. {
  5756. int status = 0;
  5757. char INFfile[MAX_STR_SIZE] = {0};
  5758. char debugFile[MAX_STR_SIZE] = {0};
  5759. struct _stat statbuf;
  5760. static char contentLength[100] = {0};
  5761. static char admservRoot[MAX_STR_SIZE] = {0};
  5762. static char serverUrl[MAX_STR_SIZE] = {0};
  5763. static char scriptName[MAX_STR_SIZE] = {0};
  5764. char szCGIArgs[MAX_STR_SIZE]= {0};
  5765. LPVOID lpMsgBuf;
  5766. /* create an .inf file to pass to index */
  5767. /* write the data to a temp file */
  5768. my_snprintf(INFfile, sizeof(INFfile), "%s\\temp%d.inf", TEMPDIR, _getpid());
  5769. myLogData("create_slapd_instance: inf file is %s", INFfile);
  5770. if (TRUE == (status = writeINFfile(INFfile)) )
  5771. {
  5772. if (status = _stat(INFfile, &statbuf))
  5773. {
  5774. lpMsgBuf = getLastErrorMessage();
  5775. DSMessageBoxOK(ERR_NO_STAT_TMP_FILE_TITLE,
  5776. ERR_NO_STAT_TMP_FILE, 0, INFfile, lpMsgBuf);
  5777. LocalFree(lpMsgBuf);
  5778. }
  5779. else
  5780. {
  5781. /* set temp file for admin output */
  5782. my_snprintf(debugFile, sizeof(debugFile), "DEBUG_FILE=%s\\debug.%d", TEMPDIR, _getpid());
  5783. _putenv(debugFile);
  5784. my_snprintf(szCGIArgs, sizeof(szCGIArgs), "\"%s\\bin\\slapd\\admin\\bin\\Install.pl\"",
  5785. serverroot);
  5786. if (mi.m_nReInstall)
  5787. {
  5788. PL_strcatn(szCGIArgs, sizeof(szCGIArgs), " -r -f ");
  5789. /* add the -r flag if reinstalling */
  5790. } else
  5791. {
  5792. PL_strcatn(szCGIArgs, sizeof(szCGIArgs), " -f ");
  5793. }
  5794. PL_strcatn(szCGIArgs, sizeof(szCGIArgs), "\"");
  5795. PL_strcatn(szCGIArgs, sizeof(szCGIArgs), INFfile);
  5796. PL_strcatn(szCGIArgs, sizeof(szCGIArgs), "\"");
  5797. myLogData("create_slapd_instance: executing %s %s",
  5798. PERL_EXE, szCGIArgs);
  5799. status = run_cgi(serverroot, PERL_EXE, szCGIArgs);
  5800. }
  5801. }
  5802. if (!getenv("USE_LOGFILE"))
  5803. _unlink(INFfile);
  5804. return status;
  5805. }
  5806. //////////////////////////////////////////////////////////////////////////////
  5807. //
  5808. // generate_mcc_bat
  5809. //
  5810. // make bat file with correct classpath, and host/port to start console
  5811. //
  5812. //
  5813. int generate_mcc_bat()
  5814. {
  5815. FILE *fp;
  5816. CHAR szFilename[MAX_STR_SIZE];
  5817. CHAR szJavaDir[MAX_STR_SIZE];
  5818. INT rc = 0;
  5819. // don't generate the file unless asked
  5820. if (!getenv("GENERATE_MCC_BAT")) {
  5821. return rc;
  5822. }
  5823. my_snprintf(szFilename, sizeof(szFilename), "%s\\%s-%s\\mcc.bat", TARGETDIR, DS_ID_SERVICE,
  5824. mi.m_szServerIdentifier);
  5825. fp = fopen(szFilename, "wb");
  5826. if (!fp)
  5827. {
  5828. DSMessageBoxOK(ERR_NO_CREATE_FILE_TITLE,
  5829. ERR_NO_CREATE_FILE, 0, szFilename);
  5830. rc = -1;
  5831. }else{
  5832. my_snprintf(szJavaDir, sizeof(szJavaDir), "%s\\java", TARGETDIR);
  5833. fprintf(fp, "pushd \"%s\"\n", szJavaDir);
  5834. /* use jre */
  5835. fprintf(fp, "%s\\jre\\bin\\jre.exe -cp ", TARGETDIR);
  5836. /* classes for classpath -cp option on jre */
  5837. fprintf(fp, "%s\\ds50.jar;", szJavaDir);
  5838. fprintf(fp, "%s\\ds50_en.jar;", szJavaDir);
  5839. fprintf(fp, "%s\\admserv45.jar;", szJavaDir);
  5840. fprintf(fp, "%s\\admserv45_en.jar;", szJavaDir);
  5841. fprintf(fp, "%s\\mcc45.jar;", szJavaDir);
  5842. fprintf(fp, "%s\\mcc45_en.jar;", szJavaDir);
  5843. fprintf(fp, "%s\\ldapjdk.jar;", szJavaDir);
  5844. fprintf(fp, "%s\\nmclf45.jar;", szJavaDir);
  5845. fprintf(fp, "%s\\nmclf45_en.jar;", szJavaDir);
  5846. fprintf(fp, "%s\\ssl.zip;", szJavaDir);
  5847. fprintf(fp, "%s\\base.jar;", szJavaDir);
  5848. fprintf(fp, "%s ", szJavaDir);
  5849. /* command and arguments to execute the console for this server */
  5850. fprintf(fp, "com.netscape.management.client.console.Console -d %s -p %d -b \"%s\"\n",
  5851. mi.m_szMCCHost, mi.m_nMCCPort, mi.m_szMCCSuffix);
  5852. fprintf(fp, "popd\n");
  5853. fclose(fp);
  5854. rc = 0;
  5855. }
  5856. return rc;
  5857. }
  5858. //
  5859. // Generates bat file to install ldap ctrs, since have to be in the same directory to get .h file
  5860. //
  5861. int generate_install_ldapctrs_bat()
  5862. {
  5863. FILE *fp;
  5864. CHAR szFilename[MAX_STR_SIZE];
  5865. INT rc = 0;
  5866. my_snprintf(szFilename, sizeof(szFilename), "%s\\%s", TARGETDIR, INSTALL_CTRS_BAT);
  5867. fp = fopen(szFilename, "wb");
  5868. if (!fp)
  5869. {
  5870. DSMessageBoxOK(ERR_NO_CREATE_FILE_TITLE,
  5871. ERR_NO_CREATE_FILE, 0, szFilename);
  5872. rc = -1;
  5873. }else{
  5874. fprintf(fp, "copy %s\\%s\\nsldapctr*.* %s\n",
  5875. TARGETDIR, BIN_SLAPD_INSTALL_BIN, WINSYSDIR);
  5876. fprintf(fp, "%s\\lodctr nsldapctrs.ini\n", WINSYSDIR);
  5877. fprintf(fp, "del %s\\nsldapctr*.*\n", WINSYSDIR);
  5878. fclose(fp);
  5879. rc = 0;
  5880. }
  5881. return rc;
  5882. }
  5883. //--------------------------------------------------------------------------//
  5884. // Install perfmon //
  5885. // Creates Registry keys and loads counters for permon etc //
  5886. //--------------------------------------------------------------------------//
  5887. BOOL _InstallPerfmon(char *szServerRoot)
  5888. {
  5889. BOOL bReturn = FALSE;
  5890. HKEY hKey;
  5891. DWORD dwDisposition;
  5892. char szKey[MAX_PATH];
  5893. char szTemp[MAX_PATH];
  5894. int maxpath = MAX_PATH;
  5895. char *reg = REGSTR_PATH_SERVICES;
  5896. char *id = SVR_ID_SERVICE;
  5897. char *ver = SVR_VERSION;
  5898. char *key = KEY_PERFORMANCE;
  5899. wsprintf(szKey, "%s\\%s%s\\%s", REGSTR_PATH_SERVICES, SVR_ID_SERVICE, SVR_VERSION, KEY_PERFORMANCE);
  5900. if(RegCreateKeyEx(HKEY_LOCAL_MACHINE, szKey, 0, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwDisposition) == ERROR_SUCCESS)
  5901. {
  5902. RegSetValueEx(hKey, "Open", 0, REG_SZ, PERF_OPEN_FUNCTION, lstrlen(PERF_OPEN_FUNCTION)+2);
  5903. RegSetValueEx(hKey, "Collect", 0, REG_SZ, PERF_COLLECT_FUNCTION, lstrlen(PERF_COLLECT_FUNCTION)+2);
  5904. RegSetValueEx(hKey, "Close", 0, REG_SZ, PERF_CLOSE_FUNCTION, lstrlen(PERF_CLOSE_FUNCTION)+2);
  5905. wsprintf(szTemp, "%s\\bin\\slapd\\server\\nsldapctr.dll", szServerRoot);
  5906. RegSetValueEx(hKey, "Library", 0, REG_SZ, szTemp, lstrlen(szTemp)+2);
  5907. RegCloseKey(hKey);
  5908. wsprintf(szTemp, "unlodctr %s%s", SVR_ID_SERVICE, SVR_VERSION);
  5909. _LaunchAndWait(szTemp, INFINITE);
  5910. generate_install_ldapctrs_bat();
  5911. wsprintf(szTemp, "%s\\%s", szServerRoot, INSTALL_CTRS_BAT);
  5912. _LaunchAndWait(szTemp, INFINITE);
  5913. DeleteFile(szTemp);
  5914. }
  5915. return(bReturn);
  5916. }
  5917. static void
  5918. CopyAndDeleteKey(
  5919. HKEY srcBase, const char *srcName,
  5920. HKEY destBase, const char *destName
  5921. )
  5922. {
  5923. DWORD index = 0;
  5924. LONG retval = 0;
  5925. HKEY srcHKEY;
  5926. HKEY destHKEY;
  5927. char className[MAX_PATH+1] = {0};
  5928. DWORD classLen = MAX_PATH+1;
  5929. DWORD nKeys = 0, maxKeyLen = 0, maxClassLen = 0, nValues = 0,
  5930. maxValueNameLen = 0, maxValueDataLen = 0;
  5931. DWORD disposition = 0;
  5932. // open the source key
  5933. retval = RegOpenKey(srcBase, srcName, &srcHKEY);
  5934. if (retval != ERROR_SUCCESS) {
  5935. myLogError("CopyAndDeleteKey: could not open src key %s: ret = %d\n",
  5936. srcName, retval);
  5937. return;
  5938. }
  5939. // get the info from the old key
  5940. retval = RegQueryInfoKey(srcHKEY, className, &classLen, 0, &nKeys, &maxKeyLen,
  5941. &maxClassLen, &nValues, &maxValueNameLen,
  5942. &maxValueDataLen, 0, 0);
  5943. if (retval != ERROR_SUCCESS) {
  5944. myLogError("CopyAndDeleteKey: could not read src key info %s: ret = %d\n",
  5945. srcName, retval);
  5946. return;
  5947. }
  5948. // create the new key based on the info in the old key
  5949. retval = RegCreateKeyEx(destBase, destName, 0, className,
  5950. REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0,
  5951. &destHKEY, &disposition);
  5952. if (retval != ERROR_SUCCESS) {
  5953. myLogError("CopyAndDeleteKey: creating new key %s: ret = %d\n",
  5954. destName, retval);
  5955. return;
  5956. }
  5957. // copy all of the values from the old key to the new key
  5958. for (index = 0; index < nValues; ++index) {
  5959. DWORD valueNameLen = maxValueNameLen+1;
  5960. DWORD valueType = 0;
  5961. DWORD valueDataLen = maxValueDataLen+1;
  5962. char *valueName = calloc(1, valueNameLen);
  5963. char *valueData = calloc(1, valueDataLen);
  5964. retval = RegEnumValue(srcHKEY, index, valueName, &valueNameLen, 0,
  5965. &valueType, valueData, &valueDataLen);
  5966. if (retval == ERROR_SUCCESS) {
  5967. retval = RegSetValueEx(destHKEY, valueName, 0, valueType,
  5968. valueData, valueDataLen);
  5969. if (retval != ERROR_SUCCESS) {
  5970. myLogError("CopyAndDeleteKey: could not write value %s to key %s\n",
  5971. valueName, destName);
  5972. }
  5973. } else {
  5974. myLogError("CopyAndDeleteKey: could not read value %d:%s from key %s\n",
  5975. index, (valueName ? valueName : "null"), destName);
  5976. }
  5977. free(valueName);
  5978. free(valueData);
  5979. }
  5980. // copy all of the sub keys as well; since we're deleting keys as we go along,
  5981. // the actual nKeys will change
  5982. if (nKeys > 0) {
  5983. for (index = nKeys; index; --index) {
  5984. DWORD keyNameLen = maxKeyLen+1;
  5985. char *keyName = calloc(1, keyNameLen);
  5986. retval = RegEnumKey(srcHKEY, index-1, keyName, keyNameLen);
  5987. if (retval == ERROR_SUCCESS) {
  5988. CopyAndDeleteKey(srcHKEY, keyName, destHKEY, keyName);
  5989. } else {
  5990. myLogError("CopyAndDeleteKey: could not get key %d:%s of nKeys %d:"
  5991. "error %d\n", index-1, (keyName ? keyName : "null"),
  5992. nKeys, retval);
  5993. }
  5994. free(keyName);
  5995. }
  5996. }
  5997. // close the destination key
  5998. retval = RegCloseKey(destHKEY);
  5999. if (retval != ERROR_SUCCESS) {
  6000. myLogError("CopyAndDeleteKey: could not close dest key %s\n",
  6001. destName);
  6002. }
  6003. // close the source key
  6004. retval = RegCloseKey(srcHKEY);
  6005. if (retval != ERROR_SUCCESS) {
  6006. myLogError("CopyAndDeleteKey: could not close source key %s\n",
  6007. srcName);
  6008. }
  6009. // delete the source key
  6010. retval = RegDeleteKey(srcBase, srcName);
  6011. if (retval != ERROR_SUCCESS) {
  6012. myLogError("CopyAndDeleteKey: could not delete source key %s\n",
  6013. srcName);
  6014. }
  6015. return;
  6016. }
  6017. // This function will rename the registry keys from the old version to
  6018. // the new version
  6019. static void
  6020. updateRegistryKeys(const char *oldVersion, const char *newVersion)
  6021. {
  6022. char oldKey[MAX_PATH] = {0};
  6023. char newKey[MAX_PATH] = {0};
  6024. int retval = 0;
  6025. DWORD index = 0;
  6026. HKEY svrHKEY;
  6027. DWORD nKeys = 0;
  6028. DWORD maxKeyLen = 0;
  6029. char *ptr = 0;
  6030. // There are three places we need to change
  6031. // the first place is under
  6032. // HKEY_LOCAL_MACHINE\SOFTWARE\Netscape\Directory\oldVersion
  6033. // we need to change oldVersion to newVersion
  6034. my_snprintf(newKey, sizeof(newKey), "%s\\%s", KEY_SOFTWARE_NETSCAPE, SVR_KEY_ROOT);
  6035. strcpy(oldKey, newKey);
  6036. if (ptr = strstr(oldKey, SVR_VERSION)) {
  6037. my_strncpy(ptr, oldVersion, strlen(oldVersion));
  6038. }
  6039. myLogData("updateRegistryKeys: copying %s to %s\n",
  6040. oldKey, newKey);
  6041. CopyAndDeleteKey(HKEY_LOCAL_MACHINE, oldKey, HKEY_LOCAL_MACHINE,
  6042. newKey);
  6043. // the second place is under
  6044. // HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\slapdoldVersoin
  6045. // we need to change oldVersion to newVersion
  6046. my_snprintf(oldKey, sizeof(oldKey), "%s\\%s%s", KEY_SERVICES, PRODUCT_NAME,
  6047. oldVersion);
  6048. my_snprintf(newKey, sizeof(newKey), "%s\\%s%s", KEY_SERVICES, PRODUCT_NAME,
  6049. SVR_VERSION);
  6050. CopyAndDeleteKey(HKEY_LOCAL_MACHINE, oldKey, HKEY_LOCAL_MACHINE,
  6051. newKey);
  6052. // the third place is under
  6053. // HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\slapd-instance
  6054. // for each instance, we need to replace the DisplayName value with
  6055. // the new display name
  6056. // open the services key
  6057. retval = RegOpenKey(HKEY_LOCAL_MACHINE, KEY_SERVICES, &svrHKEY);
  6058. // get the info from the key
  6059. retval = RegQueryInfoKey(svrHKEY, 0, 0, 0, &nKeys, &maxKeyLen,
  6060. 0, 0, 0,
  6061. 0, 0, 0);
  6062. if (retval != ERROR_SUCCESS) {
  6063. myLogError("updateRegistryKeys: could not read info %s: ret = %d\n",
  6064. KEY_SERVICES, retval);
  6065. return;
  6066. }
  6067. // iterate the keys under Services
  6068. for (index = 0; index < nKeys; ++index) {
  6069. DWORD keyNameLen = maxKeyLen+1;
  6070. char *keyName = calloc(1, keyNameLen);
  6071. retval = RegEnumKey(svrHKEY, index, keyName, keyNameLen);
  6072. if (retval == ERROR_SUCCESS && keyName &&
  6073. !strncmp(keyName, PRODUCT_NAME, strlen(PRODUCT_NAME))) {
  6074. // read the DisplayName value from the key
  6075. HKEY key;
  6076. retval = RegOpenKey(svrHKEY, keyName, &key);
  6077. if (retval == ERROR_SUCCESS) {
  6078. DWORD type = REG_SZ;
  6079. char oldValue[MAX_PATH+1] = {0};
  6080. DWORD oldValueLen = MAX_PATH+1;
  6081. char *ptr = 0;
  6082. retval = RegQueryValueEx(key, "DisplayName", 0, &type,
  6083. oldValue, &oldValueLen);
  6084. // if the DisplayName contains the old version number . . .
  6085. if ((retval == ERROR_SUCCESS) &&
  6086. (ptr = strstr(oldValue, oldVersion))) {
  6087. // . . . replace it
  6088. strncpy(ptr, SVR_VERSION, strlen(SVR_VERSION));
  6089. retval = RegSetValueEx(key, "DisplayName", 0, type,
  6090. oldValue, oldValueLen);
  6091. if (retval != ERROR_SUCCESS) {
  6092. myLogError("updateRegistryKeys: could not set value %s "
  6093. "for key %s\n",
  6094. oldValue, keyName);
  6095. }
  6096. } else {
  6097. myLogError("updateRegistryKeys: could not read DisplayName"
  6098. "from key %s:%s\n", keyName, oldValue);
  6099. }
  6100. RegCloseKey(key);
  6101. } else {
  6102. myLogError("updateRegistryKeys: could not open service key %s\n",
  6103. keyName);
  6104. }
  6105. } else {
  6106. myLogError("updateRegistryKeys: could not get key %d:%s of nKeys %d:"
  6107. "error %d\n", index, (keyName ? keyName : "null"),
  6108. nKeys, retval);
  6109. }
  6110. free(keyName);
  6111. }
  6112. RegCloseKey(svrHKEY);
  6113. // finally, remove the old Uninstall string
  6114. #define REG_UNINST "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Netscape Server Family 4.0"
  6115. myLogData("Deleting key %s", REG_UNINST);
  6116. DeleteServerRegistryKey(HKEY_LOCAL_MACHINE, REG_UNINST);
  6117. }
  6118. // This function makes sure nsperl is installed and running before the main slapd
  6119. // post install runs, which needs nsperl to run
  6120. static BOOL
  6121. NSPERLINST_PostInstall(VOID)
  6122. {
  6123. BOOL bRC = TRUE;
  6124. char *p = 0;
  6125. char instDir[BUFSIZ] = {0};
  6126. char nsPerlPostInstall[MAX_PATH] = {0};
  6127. char infFile[MAX_PATH] = {0};
  6128. char srcPath[MAX_PATH] = {0};
  6129. char destPath[MAX_PATH] = {0};
  6130. char szCurrentDir[MAX_STR_SIZE] = {0};
  6131. if (GetCurrentDirectory(MAX_STR_SIZE, szCurrentDir) == 0) {
  6132. myLogError("NSPERLINST_PostInstall could not determine the current directory");
  6133. return FALSE;
  6134. }
  6135. // hack to work around potential bug in setupsdk . . .
  6136. SetCurrentDirectory("../slapd");
  6137. my_snprintf(infFile, sizeof(infFile), "slapd.inf");
  6138. GetProductInfoStringWithTok(NSPERL_POST_INSTALL_PROG, "=", nsPerlPostInstall,
  6139. BUFSIZ, infFile);
  6140. p = strrchr(nsPerlPostInstall, '/');
  6141. if (!p)
  6142. p = strrchr(nsPerlPostInstall, '\\');
  6143. if (!p) {
  6144. // punt
  6145. myLogError("NSPERLINST_PostInstall: could not get the post install program %s"
  6146. " from the info file %s", nsPerlPostInstall, infFile);
  6147. return FALSE;
  6148. }
  6149. // get the RunPostInstall attribute from the inf; this is the name
  6150. // of the post install program
  6151. *p = 0; // p points at last dir sep in the path, so null it
  6152. my_snprintf(instDir, sizeof(instDir), "%s\\%s", TARGETDIR, nsPerlPostInstall);
  6153. p++;
  6154. // change directory to the directory of the post install program and
  6155. // execute it
  6156. if (SetCurrentDirectory(instDir) == 0) {
  6157. myLogError("NSPERLINST_PostInstall: could not change directory to %s",
  6158. instDir);
  6159. return FALSE;
  6160. }
  6161. if (_LaunchAndWait(p, INFINITE) != 0) {
  6162. myLogError("NSPERLINST_PostInstall: could not run the nsperl post install"
  6163. " program %s from directory %s", p, instDir);
  6164. SetCurrentDirectory(szCurrentDir);
  6165. return FALSE;
  6166. }
  6167. SetCurrentDirectory(szCurrentDir);
  6168. my_snprintf(srcPath, sizeof(srcPath), "%s\\nsperl.exe", instDir);
  6169. my_snprintf(destPath, sizeof(destPath), "%s\\%s", TARGETDIR, PERL_EXE);
  6170. if (FALSE == CopyFile(srcPath, destPath, FALSE)) { // FALSE to overwrite file if exists
  6171. myLogError("NSPERLINST_PostInstall: could not copy file %s to %s",
  6172. srcPath, destPath);
  6173. bRC = FALSE;
  6174. }
  6175. myLogData("Successfully installed nsPerl");
  6176. return bRC;
  6177. }
  6178. //////////////////////////////////////////////////////////////////////////////
  6179. // DSINST_PostInstall
  6180. //
  6181. // The framework calls this function to perform post-installation
  6182. // configuration. Here you should set values in any product configuration
  6183. // files, install services, add registry keys, start servers, and anything
  6184. // else that can only be done once the binaries are layed down on the disk.
  6185. // If the function succeeds return TRUE, otherwise return FALSE to indicate
  6186. // an error.
  6187. //
  6188. BOOL __declspec(dllexport)
  6189. DSINST_PostInstall(VOID)
  6190. {
  6191. // TODO: Add code to perform configuration.
  6192. BOOL rc;
  6193. myLogData("DSINST_PostInstall: BEGIN");
  6194. rc = NSPERLINST_PostInstall();
  6195. /* install perfmon*/
  6196. _InstallPerfmon(TARGETDIR);
  6197. if (1 == mi.m_nReInstall )
  6198. {
  6199. myLogData("DSINST_PostInstall: doing a reinstall");
  6200. /* if the old version is not equal to the new version, we need to
  6201. update the various registry keys */
  6202. if (strcmp(oldVersion, SVR_VERSION)) {
  6203. updateRegistryKeys(oldVersion, SVR_VERSION);
  6204. }
  6205. /* turn servers back on */
  6206. ControlSlapdServers(TARGETDIR, TRUE, TRUE);
  6207. /* do any other ReInstall things here */
  6208. }
  6209. /*create slapd instance detects reinstall and calls index with -r */
  6210. myLogData("DSINST_PostInstall: before create_slapd_instance %s", mi.m_szInstanceHostName);
  6211. if (0 == create_slapd_instance(mi.m_szInstanceHostName, TARGETDIR) )
  6212. {
  6213. if ( 0 == generate_mcc_bat() )
  6214. {
  6215. rc = TRUE;
  6216. } else
  6217. {
  6218. DSMessageBoxOK(ERR_CREATE_MCC_BAT_TITLE, ERR_CREATE_MCC_BAT, 0);
  6219. rc = FALSE;
  6220. }
  6221. } else
  6222. {
  6223. DSMessageBoxOK(ERR_CREATE_DS_INSTANCE_TITLE, ERR_CREATE_DS_INSTANCE, 0);
  6224. rc = FALSE;
  6225. }
  6226. /* turn SNMP service back on if it was running */
  6227. if ( 1 == mi.m_nSNMPOn)
  6228. {
  6229. if ( 0 == ControlServer(SNMP_SERVICE, TRUE) )
  6230. {
  6231. /* complain but continue with install */
  6232. DSMessageBoxOK(ERR_SNMP_BAD_STARTUP_TITLE, ERR_SNMP_BAD_STARTUP, 0);
  6233. }
  6234. }
  6235. return rc;
  6236. }
  6237. //--------------------------------------------------------------------------//
  6238. // //
  6239. //--------------------------------------------------------------------------//
  6240. static BOOL RemoveSNMPValue(void)
  6241. {
  6242. char line[MAX_PATH];
  6243. char NumValuesBuf[3];
  6244. DWORD Result;
  6245. HKEY hServerKey;
  6246. DWORD NumValues;
  6247. DWORD iterator;
  6248. int value_already_exists = 0;
  6249. DWORD type_buffer;
  6250. char value_data_buffer[MAX_PATH];
  6251. DWORD sizeof_value_data_buffer;
  6252. /* open registry key for Microsoft SNMP service */
  6253. my_snprintf(line, sizeof(line), "%s\\%s", KEY_SERVICES, KEY_SNMP_SERVICE);
  6254. Result = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
  6255. line,
  6256. 0,
  6257. KEY_ALL_ACCESS,
  6258. &hServerKey);
  6259. /* if Microsoft SNMP Service is installed look
  6260. for slapd snmp value to remove */
  6261. if (Result == ERROR_SUCCESS)
  6262. {
  6263. my_snprintf(line, sizeof(line),
  6264. "%s\\%s\\%s",
  6265. KEY_SOFTWARE_NETSCAPE,
  6266. SVR_KEY_ROOT,
  6267. KEY_SNMP_CURRENTVERSION);
  6268. Result = RegQueryInfoKey(hServerKey,
  6269. NULL, NULL,
  6270. NULL, NULL,
  6271. NULL, NULL,
  6272. &NumValues,
  6273. NULL, NULL,
  6274. NULL, NULL);
  6275. if (Result == ERROR_SUCCESS)
  6276. {
  6277. for(iterator = 0; iterator <= NumValues; iterator++)
  6278. {
  6279. sizeof_value_data_buffer=MAX_PATH;
  6280. my_snprintf(NumValuesBuf, sizeof(NumValuesBuf), "%d", iterator);
  6281. Result = RegQueryValueEx(hServerKey,
  6282. NumValuesBuf,
  6283. NULL,
  6284. &type_buffer,
  6285. value_data_buffer,
  6286. &sizeof_value_data_buffer);
  6287. if(!lstrcmp(value_data_buffer, line))
  6288. {
  6289. /* remove the value */
  6290. Result = RegDeleteValue(hServerKey, NumValuesBuf);
  6291. break;
  6292. }
  6293. }
  6294. }
  6295. }
  6296. RegCloseKey(hServerKey);
  6297. return (Result == ERROR_SUCCESS);
  6298. }
  6299. BOOL RemoveSNMPKeys(void)
  6300. {
  6301. char line[MAX_PATH];
  6302. BOOL bRC = TRUE;
  6303. /* open registry key for Directory SNMP s */
  6304. memset(line, '\0', MAX_PATH);
  6305. my_snprintf(line, sizeof(line), "%s\\%s\\%s", KEY_SOFTWARE_NETSCAPE, SVR_KEY_ROOT,
  6306. KEY_SNMP_CURRENTVERSION);
  6307. RegDeleteKey(HKEY_LOCAL_MACHINE, line);
  6308. memset(line, '\0', MAX_PATH);
  6309. my_snprintf(line, sizeof(line), "%s\\%s\\%s", KEY_SOFTWARE_NETSCAPE, SVR_KEY_ROOT,
  6310. SNMP_SERVICE_NAME);
  6311. RegDeleteKey(HKEY_LOCAL_MACHINE, line);
  6312. return bRC;
  6313. }
  6314. BOOL RemovePerfMon(void)
  6315. {
  6316. char szTemp[MAX_PATH];
  6317. BOOL bRC = TRUE;
  6318. // uninstall perfmon counters and keys
  6319. wsprintf(szTemp, "unlodctr %s%s", SVR_ID_SERVICE, SVR_VERSION);
  6320. _LaunchAndWait(szTemp, 10000);
  6321. wsprintf(szTemp, "%s\\%s%s\\%s", REGSTR_PATH_SERVICES,
  6322. SVR_ID_SERVICE, SVR_VERSION, KEY_PERFORMANCE);
  6323. RegDeleteKey(HKEY_LOCAL_MACHINE, szTemp );
  6324. wsprintf(szTemp, "%s\\%s%s", REGSTR_PATH_SERVICES,
  6325. SVR_ID_SERVICE, SVR_VERSION);
  6326. RegDeleteKey(HKEY_LOCAL_MACHINE, szTemp );
  6327. return bRC;
  6328. }
  6329. BOOL RemoveDirectoryRootKey()
  6330. {
  6331. char line[MAX_PATH];
  6332. BOOL bRC = TRUE;
  6333. memset(line, '\0', MAX_PATH);
  6334. my_snprintf(line, sizeof(line), "%s\\%s", KEY_SOFTWARE_NETSCAPE, DS_NAME_SHORT);
  6335. RegDeleteKey(HKEY_LOCAL_MACHINE, line);
  6336. return bRC;
  6337. }
  6338. static void
  6339. _PumpMessage(HWND hwndMsgDlg)
  6340. {
  6341. MSG msg;
  6342. while (GetMessage(&msg, NULL, 0, 0))
  6343. {
  6344. TranslateMessage(&msg);
  6345. DispatchMessage(&msg);
  6346. }
  6347. }
  6348. //////////////////////////////////////////////////////////////////////////////
  6349. // ShutdownDialogProc
  6350. //
  6351. // winproc for status window users sees when trying to shutdown instance so
  6352. // install doesn't appear to be hung
  6353. //
  6354. //
  6355. BOOL CALLBACK ShutdownDialogProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
  6356. {
  6357. int retval;
  6358. myLogData("ShutdownDialog Proc iMsg=%d wParam=%d lParam=%d", iMsg, wParam, lParam);
  6359. switch (iMsg)
  6360. {
  6361. case WM_INITDIALOG:
  6362. retval = SetWindowText(hwnd, dialogMessage);
  6363. myLogData("19 SetWindowText returns %d", retval);
  6364. if (!retval) myLogError("19 SetWindowText");
  6365. retval = SetDlgItemText(hwnd, IDC_STOPPING_SERVER_MESSAGE,
  6366. dialogMessage);
  6367. myLogData("20 SetDlgItemText returns %d", retval);
  6368. if (!retval) myLogError("20 SetDlgItemText");
  6369. myLogData("iMsg=%d WM_INITDIALOG=%d WM_CREATE=%d msg=%s",
  6370. iMsg, WM_INITDIALOG, WM_CREATE, dialogMessage);
  6371. return TRUE;
  6372. case WM_DESTROY:
  6373. PostQuitMessage(0);
  6374. break;
  6375. }
  6376. return FALSE;
  6377. }
  6378. //////////////////////////////////////////////////////////////////////////////
  6379. // shutdownDialog
  6380. //
  6381. // thread proc for creating shutdown dialog acts as win main translating and
  6382. // dispatching events
  6383. //
  6384. //
  6385. void shutdownDialog(ShutdownArg *shutdownargs)
  6386. {
  6387. CHAR dbg[MAX_STR_SIZE]="\0";
  6388. int retval;
  6389. dialogMessage = shutdownargs->pszServiceName;
  6390. myLogData("Before createDialog");
  6391. shutdownargs->hwnd = CreateDialog(mi.m_hModule,
  6392. MAKEINTRESOURCE(IDD_UNINSTALL_STATUS),
  6393. NULL,
  6394. ShutdownDialogProc);
  6395. myLogData("After createDialog");
  6396. if (shutdownargs->hwnd == NULL)
  6397. {
  6398. return;
  6399. }
  6400. CenterWindow(shutdownargs->hwnd);
  6401. retval = SetWindowText(shutdownargs->hwnd, dialogMessage);
  6402. myLogData("1 SetWindowText returns %d", retval);
  6403. retval = GetWindowText(shutdownargs->hwnd, dbg, MAX_STR_SIZE);
  6404. myLogData("GetWindowText string [%s] retval %d", dbg, retval);
  6405. retval = SetDlgItemText(shutdownargs->hwnd, IDC_STOPPING_SERVER_MESSAGE,
  6406. dialogMessage);
  6407. myLogData("3 SetDlgItemText returns %d", retval);
  6408. retval = UpdateWindow(shutdownargs->hwnd);
  6409. myLogData("5 UpdateWindow returns %d", retval);
  6410. retval = ShowWindow(shutdownargs->hwnd, SW_SHOWNORMAL);
  6411. myLogData("6 ShowWindow returns %d", retval);
  6412. retval = UpdateWindow(shutdownargs->hwnd);
  6413. myLogData("7 UpdateWindow returns %d", retval);
  6414. retval = SetWindowText(shutdownargs->hwnd, dialogMessage);
  6415. myLogData("8 SetWindowText returns %d", retval);
  6416. retval = GetWindowText(shutdownargs->hwnd, dbg, MAX_STR_SIZE);
  6417. myLogData("9 GetWindowText string [%s] retval %d", dbg, retval);
  6418. retval = UpdateWindow(shutdownargs->hwnd);
  6419. myLogData("10 retval=%d msg=%s\n", retval, dialogMessage);
  6420. _PumpMessage(shutdownargs->hwnd);
  6421. }
  6422. BOOL writeUninstINFfile(const char *filename,
  6423. const char *pszServerRoot,
  6424. const char *pszServiceName)
  6425. {
  6426. FILE *fp = fopen(filename, "wb");
  6427. CHAR szHostName[MAX_STR_SIZE]="\0";
  6428. DSGetHostName(szHostName, MAX_STR_SIZE);
  6429. if (NULL == fp)
  6430. return FALSE;
  6431. // write section header
  6432. fprintf(fp, "[uninstall]\n");
  6433. fprintf(fp, "%s= %s\n", SLAPD_KEY_FULL_MACHINE_NAME, szHostName);
  6434. fprintf(fp, "%s= %s\n", SLAPD_KEY_SERVER_ROOT, pszServerRoot);
  6435. fprintf(fp, "%s= %s\n", SLAPD_KEY_SERVER_IDENTIFIER, pszServiceName);
  6436. fprintf(fp, "%s= %s\n", GLOBAL_INF_LDAP_HOST, GetLdapHost() );
  6437. fprintf(fp, "%s= %d\n", GLOBAL_INF_LDAP_PORT, GetLdapPort() );
  6438. fprintf(fp, "%s= %s\n", SLAPD_KEY_SUFFIX, GetLdapSuffix() );
  6439. fprintf(fp, "%s= %s\n", SLAPD_KEY_SERVER_ADMIN_ID, GetLdapUser() );
  6440. fprintf(fp, "%s= %s\n", SLAPD_KEY_SERVER_ADMIN_PWD, GetLdapPassword() );
  6441. fprintf(fp, "%s= %s\n", SLAPD_INSTALL_LOG_FILE_NAME, LOGFILE );
  6442. fclose(fp);
  6443. return TRUE;
  6444. }
  6445. //////////////////////////////
  6446. //
  6447. // try to turn a server instance on or off
  6448. // displays dialog while doing so
  6449. //
  6450. //
  6451. void ControlSlapdInstance(char *pszServiceName, BOOL bOn)
  6452. {
  6453. INT shutdown_tries=0;
  6454. BOOL bServerRunning=0;
  6455. CHAR szLog[MAX_STR_SIZE]="\0";
  6456. CHAR szFormat[MAX_STR_SIZE]="\0";
  6457. ShutdownArg shutdownargs;
  6458. CHAR szMessage[MAX_STR_SIZE]="\0";
  6459. const CHAR *shortName = getShortName(pszServiceName);
  6460. myLogData("Begin ControlSlapdInstance");
  6461. if(bOn)
  6462. {
  6463. LoadString( mi.m_hModule, IDS_STARTING_SERVICE, szFormat, MAX_STR_SIZE);
  6464. }else{
  6465. LoadString( mi.m_hModule, IDS_STOPPING_SERVICE, szFormat, MAX_STR_SIZE);
  6466. }
  6467. my_snprintf(szMessage, sizeof(szMessage), szFormat, shortName);
  6468. myLogData(szMessage);
  6469. ZeroMemory(&shutdownargs, sizeof(shutdownargs));
  6470. /* strategy here is to try and turn on/off the server,
  6471. sometimes it may take more than the first try
  6472. if can't do it after N tries then give up
  6473. and warn user */
  6474. /* check for opposite of bOn (ie starting server bOn = true, check if its down = false) */
  6475. while ( shutdown_tries < MAX_SLAPD_SHUTDOWN_TRIES
  6476. && (bOn != (bServerRunning = isServiceRunning( pszServiceName ) ) ) )
  6477. {
  6478. /* try to turn of the server */
  6479. my_snprintf(szLog, sizeof(szLog), szMessage);
  6480. LogData(NULL, szLog);
  6481. myLogData(szLog);
  6482. /* setup and launch thread to display window to user
  6483. so it doesn't think install is hung */
  6484. shutdownargs.pszServiceName = szMessage;
  6485. _beginthread(shutdownDialog, 0, &shutdownargs);
  6486. ControlServer( pszServiceName, bOn );
  6487. /* give it some time to shutdown */
  6488. /* unneeded? */
  6489. if(bOn)
  6490. {
  6491. LoadString( mi.m_hModule, IDS_WAIT_SERVICE_START, szFormat, MAX_STR_SIZE);
  6492. }else{
  6493. LoadString( mi.m_hModule, IDS_WAIT_SERVICE_STOP, szFormat, MAX_STR_SIZE);
  6494. }
  6495. my_snprintf(szLog, sizeof(szLog), szFormat, shortName);
  6496. LogData(NULL, szLog);
  6497. myLogData(szLog);
  6498. Sleep(SLAPD_SHUTDOWN_TIME_MILLISECONDS);
  6499. shutdown_tries++;
  6500. }
  6501. if ((shutdown_tries > 0) && (shutdownargs.hwnd > 0))
  6502. {
  6503. SendMessage(shutdownargs.hwnd, WM_DESTROY, 0, 0);
  6504. }
  6505. if ( MAX_SLAPD_SHUTDOWN_TRIES == shutdown_tries)
  6506. {
  6507. /* check if it got it the last time */
  6508. /* it should be whatever user wanted in bOn at this point*/
  6509. if (bOn == (bServerRunning = isServiceRunning( pszServiceName ) ) )
  6510. {
  6511. /* warn user, ask if they want to continue */
  6512. if ( IDOK == DSMessageBox(MB_OKCANCEL, ERR_SLAPD_SHUTDOWN_TITLE,
  6513. ERR_SLAPD_SHUTDOWN, shortName, shortName) )
  6514. {
  6515. } else
  6516. {
  6517. UINT uExitCode = 1;
  6518. /* stevross: use ExitProcess until admin server provides us with
  6519. better way to exit framework and cleanup */
  6520. ExitProcess(uExitCode);
  6521. }
  6522. }
  6523. }
  6524. myLogData("End ControlSlapdInstance");
  6525. }
  6526. static void ConvertPasswordToPin(char *pszServerRoot, char *pszServiceName)
  6527. {
  6528. CHAR szFormat[MAX_STR_SIZE*4]="\0";
  6529. CHAR szCurrentDir[MAX_STR_SIZE]="\0";
  6530. CHAR szNewDir[MAX_STR_SIZE]="\0";
  6531. myLogData("Begin ConvertPasswordToPin");
  6532. /* get current dir so we have it for later */
  6533. if (GetCurrentDirectory(MAX_STR_SIZE, szCurrentDir) == 0)
  6534. {
  6535. myLogData("ConvertPasswordToPin: could not get current directory: %d",
  6536. GetLastError());
  6537. return;
  6538. }
  6539. /* have to be in the alias directory to run this */
  6540. my_snprintf(szNewDir, sizeof(szNewDir), "%s\\alias", pszServerRoot);
  6541. /* change current dir to the alias directory */
  6542. if (SetCurrentDirectory(szNewDir) == 0)
  6543. {
  6544. myLogData("ConvertPasswordToPin: could not set current directory to %s: %d",
  6545. szNewDir, GetLastError());
  6546. return;
  6547. }
  6548. /* spawn the perl script which does the conversion */
  6549. my_snprintf(szFormat, sizeof(szFormat), "\"%s\\bin\\slapd\\admin\\bin\\migratePwdFile\" \"%s\" %s",
  6550. pszServerRoot, pszServerRoot, pszServiceName);
  6551. run_cgi(pszServerRoot, PERL_EXE, szFormat);
  6552. if (SetCurrentDirectory(szCurrentDir) == 0)
  6553. {
  6554. myLogData("ConvertPasswordToPin: could not set current directory back to %s: %d",
  6555. szCurrentDir, GetLastError());
  6556. return;
  6557. }
  6558. myLogData("End ConvertPasswordToPin");
  6559. }
  6560. static void ReinstallUpgradeServer(char *pszServerRoot, char *pszServiceName)
  6561. {
  6562. CHAR szFormat[MAX_STR_SIZE*4]="\0";
  6563. CHAR szCurrentDir[MAX_STR_SIZE]="\0";
  6564. myLogData("Begin ReinstallUpgradeServer");
  6565. /* get current dir so we have it for later */
  6566. if (GetCurrentDirectory(MAX_STR_SIZE, szCurrentDir) == 0)
  6567. {
  6568. myLogData("ReinstallUpgradeServer: could not get current directory: %d",
  6569. GetLastError());
  6570. return;
  6571. }
  6572. /* have to be in the server root directory to run this */
  6573. if (SetCurrentDirectory(pszServerRoot) == 0)
  6574. {
  6575. myLogData("ReinstallUpgradeServer: could not set current directory to %s: %d",
  6576. pszServerRoot, GetLastError());
  6577. return;
  6578. }
  6579. /* spawn the perl script which does the conversion */
  6580. my_snprintf(szFormat, sizeof(szFormat), "\"%s\\bin\\slapd\\admin\\bin\\upgradeServer\" \"%s\" %s",
  6581. pszServerRoot, pszServerRoot, pszServiceName);
  6582. run_cgi(pszServerRoot, PERL_EXE, szFormat);
  6583. if (SetCurrentDirectory(szCurrentDir) == 0)
  6584. {
  6585. myLogData("ReinstallUpgradeServer: could not set current directory back to %s: %d",
  6586. szCurrentDir, GetLastError());
  6587. return;
  6588. }
  6589. myLogData("End ReinstallUpgradeServer");
  6590. }
  6591. BOOL RemoveSlapdInstance(LPCSTR pszServerRoot, char *pszServiceName)
  6592. {
  6593. int status = 0;
  6594. char szINFfile[MAX_STR_SIZE] = "\0";
  6595. CHAR szCGIArgs[MAX_STR_SIZE]="\0";
  6596. /* try to turn of service */
  6597. ControlSlapdInstance(pszServiceName, FALSE);
  6598. /* now try to remove the instance */
  6599. /* call remove cgi with inf */
  6600. my_snprintf(szINFfile, sizeof(szINFfile), "%s/unin%d.inf", TEMPDIR, _getpid());
  6601. writeUninstINFfile( szINFfile, pszServerRoot, pszServiceName);
  6602. my_snprintf(szCGIArgs, sizeof(szCGIArgs), " -f \"%s\"", szINFfile);
  6603. /* remove this instance */
  6604. status = run_cgi(pszServerRoot, "bin\\slapd\\admin\\bin\\ds_remove.exe", szCGIArgs);
  6605. /* remove temp inffile */
  6606. _unlink(szINFfile);
  6607. return (status == 0); /* return true if run_cgi succeeded */
  6608. }
  6609. BOOL RemoveMiscRegistryEntries(void)
  6610. {
  6611. BOOL bRC = TRUE;
  6612. RemoveSNMPKeys();
  6613. RemoveSNMPValue();
  6614. return bRC;
  6615. }
  6616. BOOL RemoveMiscSlapdFiles(pszServerRoot)
  6617. {
  6618. char *miscFilesList[] =
  6619. {
  6620. "dsgw",
  6621. "plugins\\slapd",
  6622. "plugins\\snmp\\netscape-ldap.mib",
  6623. "bin\\slapd",
  6624. "manual\\slapd",
  6625. "relnotes.gif",
  6626. "relnotes.html",
  6627. "slapd.txt",
  6628. "unsynch.exe",
  6629. "mcc.bat",
  6630. "authdb",
  6631. "setup\\slapd",
  6632. "ldap.info",
  6633. NULL
  6634. };
  6635. int i;
  6636. CHAR szFileName[MAX_STR_SIZE];
  6637. for(i=0; miscFilesList[i] != NULL; i++)
  6638. {
  6639. memset(szFileName, '\0', MAX_STR_SIZE);
  6640. my_snprintf(szFileName, sizeof(szFileName), "%s\\%s", pszServerRoot, miscFilesList[i] );
  6641. DeleteRecursively(szFileName);
  6642. }
  6643. return TRUE;
  6644. }
  6645. //////////////////////////////////////////////////////////////////////////////
  6646. // PreUninst
  6647. //
  6648. //
  6649. // Do things before uninstalling like turn off the server
  6650. //
  6651. //
  6652. //
  6653. //
  6654. BOOL __declspec(dllexport)
  6655. DSINST_PreUnInstall(LPCSTR pszServerRoot)
  6656. {
  6657. BOOL rc = TRUE;
  6658. BOOL snmpstatus;
  6659. WIN32_FIND_DATA fileData;
  6660. HANDLE hFileHandle;
  6661. CHAR szCurrentDir[MAX_STR_SIZE]="\0";
  6662. /* for now just turn of the one instance we install */
  6663. /* later look in directory for anything slapd- and turn that off */
  6664. /* stevross: do this here until decide what to do with
  6665. DeleteServerRegistryKeys in Remove Instance */
  6666. /* get current dir so we have it for later */
  6667. GetCurrentDirectory(MAX_STR_SIZE, szCurrentDir);
  6668. /* change current dir to server root */
  6669. SetCurrentDirectory(pszServerRoot);
  6670. /* Turn off SNMP Service if Running */
  6671. snmpstatus = getSNMPStatus();
  6672. /* remove SNMP keys and any other Misc stuff */
  6673. RemoveMiscRegistryEntries();
  6674. hFileHandle = FindFirstFile("slapd-*", &fileData);
  6675. if( INVALID_HANDLE_VALUE != hFileHandle)
  6676. {
  6677. rc = RemoveSlapdInstance(pszServerRoot, fileData.cFileName);
  6678. while(TRUE == FindNextFile(hFileHandle, &fileData) )
  6679. {
  6680. BOOL status = RemoveSlapdInstance(pszServerRoot, fileData.cFileName);
  6681. /* we want to report failure even if only 1 instance removal fails */
  6682. if (rc)
  6683. {
  6684. rc = status;
  6685. }
  6686. }
  6687. FindClose(hFileHandle);
  6688. }
  6689. /* turn SNMP service back on if it was running */
  6690. if (snmpstatus)
  6691. {
  6692. if( 1 == mi.m_nSNMPOn)
  6693. {
  6694. if( 0 == ControlServer(SNMP_SERVICE, TRUE) )
  6695. {
  6696. /* complain but continue with install */
  6697. DSMessageBoxOK(ERR_SNMP_BAD_STARTUP_TITLE,
  6698. ERR_SNMP_BAD_STARTUP, 0);
  6699. }
  6700. }
  6701. }
  6702. /* set back to previous current directory */
  6703. SetCurrentDirectory(szCurrentDir);
  6704. /* unfortunately, if we just return FALSE here, uninstall will continue
  6705. happily along, and ultimately remove the uninst.exe program which we
  6706. need to run again after we figure out what went wrong
  6707. So, we must exit here
  6708. */
  6709. if (!rc) {
  6710. DSMessageBoxOK(ERR_UNINSTALL_DS_TITLE,
  6711. ERR_UNINSTALL_DS, 0, LOGFILE);
  6712. ExitProcess(1);
  6713. }
  6714. return rc;
  6715. }
  6716. //////////////////////////////////////////////////////////////////////////////
  6717. // PostUninst
  6718. //
  6719. //
  6720. // Clean up registry keys etc
  6721. //
  6722. //
  6723. //
  6724. //
  6725. BOOL __declspec(dllexport)
  6726. DSINST_PostUnInstall(LPCSTR pszServerRoot)
  6727. {
  6728. BOOL bRC = TRUE;
  6729. /* remove misc files */
  6730. RemovePerfMon();
  6731. RemoveMiscSlapdFiles(pszServerRoot);
  6732. RemoveDirectoryRootKey();
  6733. return bRC;
  6734. }
  6735. //////////////////////////////////////////////////////////////////////////////
  6736. // DllMain
  6737. //
  6738. // The Windows DLL main entry point. Called upon loading the DLL into memory.
  6739. // Perform all initialization in the DLL_PROCESS_ATTACH reason handler, and
  6740. // release any resources that you have allocated in the DLL_PROCESS_DETACH
  6741. // message handler. See the Windows SDK documentation for more information
  6742. // on this function.
  6743. //
  6744. BOOL WINAPI
  6745. DllMain(HANDLE hModule, ULONG ulReasonForCall, LPVOID lpReserved)
  6746. {
  6747. switch (ulReasonForCall)
  6748. {
  6749. case DLL_PROCESS_ATTACH:
  6750. mi.m_hModule = hModule;
  6751. StartWSA();
  6752. initialize_module();
  6753. /* set default server settings */
  6754. set_default_ldap_settings();
  6755. break;
  6756. case DLL_PROCESS_DETACH:
  6757. break;
  6758. case DLL_THREAD_ATTACH:
  6759. break;
  6760. case DLL_THREAD_DETACH:
  6761. break;
  6762. }
  6763. return TRUE;
  6764. }
  6765. static void
  6766. fixDN(char *dn)
  6767. {
  6768. if (dn && *dn)
  6769. {
  6770. char *utf8dn = localToUTF8(dn);
  6771. char *localdn = NULL;
  6772. dn_normalize_convert(utf8dn);
  6773. localdn = UTF8ToLocal(utf8dn);
  6774. strcpy(dn, localdn);
  6775. nsSetupFree(utf8dn);
  6776. nsSetupFree(localdn);
  6777. }
  6778. }
  6779. static void
  6780. fixURL(char *url)
  6781. {
  6782. if (url && *url)
  6783. {
  6784. char host[MAX_STR_SIZE];
  6785. int port;
  6786. char base[MAX_STR_SIZE];
  6787. GetURLComponents(url, host, &port, base);
  6788. fixDN(base);
  6789. my_snprintf(url, MAX_STR_SIZE, "ldap://%s:%d/%s", host, port, base);
  6790. }
  6791. }
  6792. static void
  6793. normalizeDNs()
  6794. {
  6795. fixDN(mi.m_szMCCSuffix);
  6796. fixDN(mi.m_szUGSuffix);
  6797. fixDN(mi.m_szInstallDN);
  6798. fixDN(mi.m_szInstanceSuffix);
  6799. fixDN(mi.m_szInstanceUnrestrictedUser);
  6800. fixDN(mi.m_szSupplierDN);
  6801. fixDN(mi.m_szChangeLogSuffix);
  6802. fixDN(mi.m_szConsumerDN);
  6803. fixDN(mi.m_szConsumerBindAs);
  6804. fixDN(mi.m_szSupplierBindAs);
  6805. fixDN(mi.m_szConsumerRoot);
  6806. fixDN(mi.m_szSupplierRoot);
  6807. fixURL(mi.m_szLdapURL);
  6808. fixURL(mi.m_szUserGroupURL);
  6809. }
  6810. /*
  6811. Usage:
  6812. DSMessageBox(type, titleKey, msgKey, titlearg, msgarg1, ..., msgargN);
  6813. */
  6814. int
  6815. DSMessageBox(UINT type, UINT titleKey, UINT msgKey, const char *titlearg, ...)
  6816. {
  6817. int retval = 0;
  6818. va_list ap;
  6819. CHAR msgFormat[MAX_STR_SIZE] = {0};
  6820. CHAR msg[MAX_STR_SIZE*2] = {0};
  6821. CHAR titleFormat[MAX_STR_SIZE] = {0};
  6822. CHAR title[MAX_STR_SIZE] = {0};
  6823. LoadString(mi.m_hModule, msgKey, msgFormat, MAX_STR_SIZE);
  6824. if (!msgFormat[0])
  6825. return retval;
  6826. if (titleKey >= 0)
  6827. LoadString(mi.m_hModule, titleKey, titleFormat, MAX_STR_SIZE);
  6828. va_start(ap, titlearg);
  6829. _vsnprintf(msg, sizeof(msg), msgFormat, ap);
  6830. va_end(ap);
  6831. msg[sizeof(msg)-1] = (char)0;
  6832. LogData(NULL, msg);
  6833. myLogData(msg);
  6834. if (SILENTMODE != MODE)
  6835. {
  6836. if (titleFormat[0])
  6837. {
  6838. my_snprintf(title, sizeof(title), titleFormat, titlearg);
  6839. retval = NsSetupMessageBox(NULL, msg, title, type);
  6840. }
  6841. else
  6842. retval = NsSetupMessageBox(NULL, msg, NULL, type);
  6843. }
  6844. else
  6845. {
  6846. retval = IDOK; /* force OK for silent mode */
  6847. }
  6848. return retval;
  6849. }
  6850. /*
  6851. Usage:
  6852. DSMessageBoxOK(titleKey, msgKey, titlearg, msgarg1, ..., msgargN);
  6853. */
  6854. int
  6855. DSMessageBoxOK(UINT titleKey, UINT msgKey, const char *titlearg, ...)
  6856. {
  6857. int retval = 0;
  6858. va_list ap;
  6859. CHAR msgFormat[MAX_STR_SIZE] = {0};
  6860. CHAR msg[MAX_STR_SIZE*2] = {0};
  6861. CHAR titleFormat[MAX_STR_SIZE] = {0};
  6862. CHAR title[MAX_STR_SIZE] = {0};
  6863. LoadString(mi.m_hModule, msgKey, msgFormat, MAX_STR_SIZE);
  6864. if (!msgFormat[0])
  6865. return retval;
  6866. if (titleKey >= 0)
  6867. LoadString(mi.m_hModule, titleKey, titleFormat, MAX_STR_SIZE);
  6868. va_start(ap, titlearg);
  6869. _vsnprintf(msg, sizeof(msg), msgFormat, ap);
  6870. va_end(ap);
  6871. msg[sizeof(msg)-1] = (char)0;
  6872. LogData(NULL, msg);
  6873. if (MODE != SILENTMODE)
  6874. {
  6875. if (titleFormat[0])
  6876. {
  6877. my_snprintf(title, sizeof(title), titleFormat, titlearg);
  6878. retval = NsSetupMessageBox(NULL, msg, title, MB_OK);
  6879. }
  6880. else
  6881. retval = NsSetupMessageBox(NULL, msg, NULL, MB_OK);
  6882. }
  6883. else
  6884. {
  6885. myLogData(msg); /* log the message */
  6886. retval = IDOK; /* force true return if silent mode */
  6887. }
  6888. return retval;
  6889. }