Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Dim strUsername as String
Dim ADPath as String
Dim strRealName as String
strUserName = HttpContext.Current.User.Identity.Name
If InStr(strUserName, "Domain1") Then
strUserName = strUserName.Replace("DOMAIN1\", "")
strADPath = "DC1.DOMAIN1.com"
ElseIf InStr(strUserName, "DOMAIN2") Then
strUserName = strUserName.Replace("DOMAIN2\", "")
strADPath = "DC1.DOMAIN2.com"
End If
IMPORTS System.DirectoryServices
Public Class _Default
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents lblUserName As System.Web.UI.WebControls.Label
Protected WithEvents Table1 As System.Web.UI.WebControls.Table
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents Label2 As System.Web.UI.WebControls.Label
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
SetupSession()
End Sub
Sub SetupSession()
Dim strUserName As String
Dim strRealName As String
Dim strADPath As String
strUserName = HttpContext.Current.User.Identity.Name
If InStr(strUserName, "Domain1") Then
strUserName = strUserName.Replace("DOMAIN1\", "")
strADPath = "DC1.DOMAIN1.com"
ElseIf InStr(strUserName, "DOMAIN2") Then
strUserName = strUserName.Replace("DOMAIN2\", "")
strADPath = "DC1.DOMAIN2.com"
End If
Dim Entry As DirectoryEntry = New DirectoryEntry("LDAP://" & strADPath, "DOMAIN1\GUEST", "GUESTPWD5")
Dim Searcher As DirectorySearcher = New DirectorySearcher(Entry)
Dim result As System.DirectoryServices.SearchResult
Try
Searcher.Filter = ("(anr=" & strUserName & ")")
result = Searcher.FindOne()
strRealName = (result.GetDirectoryEntry().Name).Replace("CN=", "").Replace("\", "")
Catch ex As Exception
Dim debug As String = ex.Message
End Try
strRealName = (result.GetDirectoryEntry().Name).Replace("CN=", "").Replace("\", "")
strRealName = result.Properties("givenName")(0).ToString() & " " & result.Properties("sn")(0).ToString()
Searcher.PropertiesToLoad.Add("sAMAccountName") ' // AD account name
Searcher.PropertiesToLoad.Add("givenName") '; // user's first name
Searcher.PropertiesToLoad.Add("sn") '; // user's surname