Get user information from active directory asp.net webforms c# -
i got webforms hosted iis
you can log in webform site using active directory username , password
how other information of user first , last name active directory current code in page load after success log in.
protected void page_load(object sender, eventargs e) { formsidentity id = (formsidentity)user.identity; formsauthenticationticket ticket = id.ticket; response.write("<p/>ticketname: " + ticket.name); //this ticket.name current username logged form response.write("<br/>cookie path: " + ticket.cookiepath); response.write("<br/>ticket expiration: " + ticket.expiration.tostring()); response.write("<br/>expired: " + ticket.expired.tostring()); response.write("<br/>persistent: " + ticket.ispersistent.tostring()); response.write("<br/>issuedate: " + ticket.issuedate.tostring()); response.write("<br/>userdata: " + ticket.userdata); response.write("<br/>version: " + ticket.version.tostring()); }
additional info, use authentication mode="forms" in web.config framework 4.0
try use principalcontext
. example check user password manually, can use code:
using (var context = new principalcontext(contexttype.domain, "myadname")) { var isvaliduser = context.validatecredentials(model.username, model.password); if (!isvaliduser) { //do staff } }
you can find want in context
.
and also, please check post : get first name last name of logedin windows user?
Comments
Post a Comment