Hi everybody, Can you pls help me how to paste the results in the code below? I want to use "GetUserDetails". Thanks alot <script runat="server"> Public Sub GetUserDetails(ByVal domain As String, ByVal username As String, ByVal pwd As String) Dim domainAndUsername
As [String] = domain & "\" & username Dim path As String = "LDAP://crazyjohns.com.au/DC=crazyjohns, DC=com, DC=au" Dim fullname As String Dim filterAttribute As String Dim email As String 'Dim resultemail As String Dim groupName As String Dim entry As New
DirectoryEntry(path, domainAndUsername, pwd) Try 'Bind to the native AdsObject to force authentication. Dim obj As Object = entry.NativeObject Dim search As New DirectorySearcher(entry) search.Filter = "(SAMAccountName=" & username & ")" search.PropertiesToLoad.Add("cn")
Dim result As SearchResult = search.FindOne() 'Update the new path to the user in the directory. path = result.Path filterAttribute = CType(result.Properties("cn")(0), String) fullname = CType(result.Properties("cn")(0), String) search.PropertiesToLoad.Add("mail")
Dim resultemail As SearchResult = search.FindOne() email = CType(resultemail.Properties("mail")(0), String) search.PropertiesToLoad.Add("MemberOf") Dim resultgp As SearchResult = search.FindOne() groupName = CType(resultgp.Properties("MemberOf")(0), String)
Catch ex As Exception 'Throw New Exception("Error obtaining user details. " + ex.Message) End Try End Sub </script> <form id="Form1" method="post" runat="server">
</form> <script runat="server"> sub Page_Load(sender as object, e as EventArgs) Response.write(result.GetUserDetails().username) 'Response.Write(result.GetUserDetails().Path) 'Response.Write(result.GetDirectoryEntry().Path) 'lblName.Text = "Hello " + Context.User.Identity.name
& "." 'lblAuthType.Text = "You were authenticated using " & Context.User.Identity.AuthenticationType & "." 'lblAuthType.Text = "You are authenticated to see this site." end sub </script> </form>
pige
Member
245 Points
49 Posts
Asp.net_LDAP_ActiveDirectory
Aug 24, 2004 11:43 PM|LINK
</form> <script runat="server"> sub Page_Load(sender as object, e as EventArgs) Response.write(result.GetUserDetails().username) 'Response.Write(result.GetUserDetails().Path) 'Response.Write(result.GetDirectoryEntry().Path) 'lblName.Text = "Hello " + Context.User.Identity.name & "." 'lblAuthType.Text = "You were authenticated using " & Context.User.Identity.AuthenticationType & "." 'lblAuthType.Text = "You are authenticated to see this site." end sub </script> </form>