Last post Mar 05, 2011 11:35 AM by MarcoAlv
Mar 02, 2011 06:07 AM|rashedimo|LINK
may i know where is the error , i tried so many to figure out but i was not able
MultiView1.ActiveViewIndex = 1
UserName0 = System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString
txtusername.Text = dServObj.Properties("FullName"
txtusername.Text = "you
Mar 02, 2011 03:12 PM|MarcoAlv|LINK
If you're aiming to collect data out of Active Directory, I think the name is splitted on two (GivenName = Fist Name and sn = Last Name).
Try this code if that's the case,
'Creates a Directory Entry Instance with the Username and Password provided
Dim deSystem As New DirectoryEntry("LDAP:...", User, Pass)
'Authenticacion type Secure
deSystem.AuthenticationType = AuthenticationTypes.Secure
'Creates a Directory Searcher Instance
Dim dsSystem As New DirectorySearcher(deSystem)
'sAMAccountName is equal to our username passed in.
dsSystem.Filter = "sAMAccountName=" & _Username
'Properties that the Procedures will load from Active Directory
'Find the user data
Dim srSystem As SearchResult = dsSystem.FindOne()
'Obtains the properties recently loaded
varName = srSystem.Properties("givenName").Item(0).ToString
varLastName = srSystem.Properties("sn").Item(0).ToString
'Return the full Name
Return varName & " " & varLastName
Catch ex As Exception
'Return an error if found
I hope this can help you out.
Mar 05, 2011 01:59 AM|rashedimo|LINK
hi Marco and theanks for your help
i don't want to assign specefic user name or password i want it to be inhireted from this code which it will get the domain\username
would you mind telling me how to fix it ?
Mar 05, 2011 11:35 AM|MarcoAlv|LINK
Can you post the error you're getting? Or at least explain to us what is the current output from your code.
Also, can you post the membership and role tags out of your web.config file?
One thing I'm sure, you need valid credentials to extract information out of Active Directory but you never know, I might be wrong about this.