How to integrate a Web application with VGWP ?
To integrate Visual Guard Web Portal in your web application you have to:
- Add the assemblies of Visual Guard as references of your project.
- Integrate Visual Guard in the code of your application.
- Create a Visual Guard repository and declare your application using the
Visual Guard console. This repository will contain all security items (users,
roles, permissions …) of your application. - Generate the Visual Guard configuration files
using the Visual Guard console. These configuration files will be
needed to connect your application to the repository. - Grant read/write permissions to the repository.
Prerequisites:
Step 1:

Step 2:

Step 3:

Step 4:

Step 5:

Step 6:

Step 7:

Step 8:

Step 9:

Authenticating a user with Visual Guard Web Portal.
using Novalys.VisualGuard.Security.Membership; using Novalys.VisualGuard.Security.Repository; using Novalys.VisualGuard.Security.Token; VGWebPortal portal = VGSecurityManager.Runtime.WebPortals.GetWebPortal(this.WebPortalId); if (null != portal) { String WebPortalURL = portal.Url; WebPortalURL = String.Concat(WebPortalURL, "?", "WReply=ReplyURL.aspx", "&", "hl=en-us"); HttpContext.Current.Response.Redirect(WebPortalURL, true); }
VGToken vgToken = VGSecurityManager.Runtime.Principal.Token; if (null != vgToken) { string token = vgToken.Data; NameValueCollection data = new NameValueCollection(); data.Add("VGToken", token); RedirectAndPOST(this.Page, this.RedirectURL, data); }
public void RedirectAndPOST(Page page, string destinationUrl, NameValueCollection data) { string strForm = PreparePOSTForm(destinationUrl, data); page.Controls.Add(new LiteralControl(strForm)); }
private String PreparePOSTForm(string url, NameValueCollection data) { string formID = "PostForm"; StringBuilder strForm = new StringBuilder(); strForm.Append("<form id=\"" + formID + "\" name=\"" + formID + "\" action=\"" + url + "\" method=\"POST\">"); foreach (string key in data) { strForm.Append("<input type=\"hidden\" name=\"" + key + "\" value=\"" + data[key] + "\">"); } strForm.Append("</form>"); StringBuilder strScript = new StringBuilder(); strScript.Append("<script language='javascript'>"); strScript.Append("var v" + formID + " = document." + formID + ";"); strScript.Append("v" + formID + ".submit();"); strScript.Append("</script>"); return strForm.ToString() + strScript.ToString(); }