Today, there is a strange demand. The Domain Controller's computer uses its account to log on to the computer to log on to the website (ASP. NET). Below is a promptCode
/// <Summary> /// Read and verify login user information and Set permissions /// </Summary> Public Bool Checkuserandsetcompetence (){ String Message = String . Empty; String Adtest =User. Identity. Name; String [] Ad = adtest. Split ( ' \\ ' ); String Userdomain = AD [ 0 ]. Tostring (). Trim (); String Useraccount = AD [ 1 ]. Tostring (). Trim (); /// /Prevent duplicate accounts If (Userdomain = " USA " ) Useraccount = @" USA \ " + Useraccount; If (Userdomain = " APR " ) Useraccount = @" APR \ " + Useraccount; message = Securityservice. checkuseraccount (useraccount ); // Check the user and set the user's permission information If (Message = String . Empty) {response. Cookies [useraccount]. Value = " 0 " ; Response. Redirect ( " Default. aspx " );} If (! String . Isnullorempty (Message) {uihelper. Alert ( This . Page, message ); Return False ;} Return True ;}
As shown above, the main code is:
StringAdtest = user. Identity. Name;