Advertisement
core_st

ServerLookupWebDomino

Sep 9th, 2014
3,366
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. tmpDebug := "";
  2. tmpNSFPath := @ReplaceSubstring(@URLDecode( "Domino"; @UrlQueryString("nsfpath") );"/";"\\");
  3. tmpServers := @DbLookup( "":"" ; "":"cldbdir.nsf" ; "($Pathname)" ; tmpNSFPath; "CanonicalServername");
  4. tmpServers:=@If(@IsError(tmpServers);"";tmpServers);
  5. REM {Lookup home mail server };
  6. tmpHomeServer:=@Name([Canonicalize];@NameLookup( [NoUpdate];@UserName; "MailServer" ));
  7. REM {Is Home Mail server in list of servers, then move this up to the front of the list};
  8. tmpServers := @If(@IsMember(tmpHomeServer;tmpServers); tmpHomeServer : @Transform(tmpServers;"x";@If(x=tmpHomeServer;@Nothing;x));tmpServers);
  9. tmpDebug := tmpDebug + "ReplicaServers:" + @Implode(tmpServers;",");
  10. tmpDNSNames := "";
  11. tmpClusterName := "";
  12. tmpClusterServers := "";
  13. REM {If no servers found, then db is in a different cluster, return list of cluster servers, with home server in front of list};
  14. tmpServers := @If(tmpServers="" | @Elements(tmpServers)=0;
  15.   @Do(
  16.     tmpDebug := tmpDebug + "Looking for cluster servers;";
  17.     tmpClusterName := @Subset(@DbLookup("":""; "":"names.nsf"; "($ServersLookup)"; tmpHomeServer; "ClusterName"); 1);
  18.     tmpClusterServers := @DbLookup( "":""; "":"names.nsf"; "($Clusters)"; tmpClusterName; "$0");
  19.   tmpClusterServers := @Transform(tmpClusterServers;"x";
  20. @If(x=tmpHomeServer;@Nothing;@Name([Canonicalize];x)));
  21.     tmpClusterServers := @If(@IsMember(tmpHomeServer;tmpClusterServers); tmpHomeServer : @Transform(tmpClusterServers;"x";
  22. @If(x=tmpHomeServer;@Nothing;x));tmpClusterServers);
  23.     tmpClusterServers);
  24.   tmpServers);
  25. tmpLimit:=@Elements(tmpServers)+1;
  26. @For(n:=1;
  27. n<tmpLimit;
  28. n:=n+1;
  29. tmpHTTPHostNameALT:=@Subset(@DbLookup( "":"" ; "":"names.nsf" ; "($ServersLookup)" ; tmpServers[n] ; "HTTP_Hostname");1);
  30. tmpServerFQDN:=@Subset(@DbLookup( "":"" ; "":"names.nsf" ; "($ServersLookup)" ; tmpServers[n] ; "SMTPFullHostDomain");1);
  31. tmpString:=tmpString+@Text(n)+tmpHTTPHostNameAlt+tmpServerFQDN;
  32. tmpDNSNames := @If(@Length(tmpDNSNames)>0;tmpDNSNames+",";"") + @LowerCase(@If (tmpHTTPHostNameALT!="";tmpHTTPHostNameALT;tmpServerFQDN))
  33. );
  34. @If(tmpClusterName="";@SetHTTPHeader("X-Domino-ReplicaServers";tmpDNSNames);@SetHTTPHeader("X-Domino-ClusterServers";tmpDNSNames));
  35. @SetHTTPHeader("Cache-control";"no-store");
  36. @If(tmpDebug="";"";"<script>"+tmpDebug+"</script>")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement