/// <summary> /// Logon a user. /// </summary> /// <param name="username">The username.</param> /// <param name="domain">The user's domain.</param> /// <param name="password">The user's password.</param> /// <param name="logon_type">The logon token's type.</param> /// <param name="groups">Optional list of additonal groups to add.</param> /// <returns>The logged on token.</returns> public static NtToken GetLogonUserToken(string username, string domain, string password, SecurityLogonType logon_type, IEnumerable <UserGroup> groups) { switch (logon_type) { case SecurityLogonType.Batch: case SecurityLogonType.Interactive: case SecurityLogonType.Network: case SecurityLogonType.NetworkCleartext: case SecurityLogonType.NewCredentials: case SecurityLogonType.Service: break; default: throw new ArgumentException("Invalid logon type for Logon"); } if (groups != null) { return(LogonUtils.Logon(username, domain, password, logon_type, groups)); } else { return(LogonUtils.Logon(username, domain, password, logon_type)); } }
/// <summary> /// Logon a user using S4U /// </summary> /// <param name="user">The username.</param> /// <param name="realm">The user's realm.</param> /// <param name="logon_type"></param> /// <returns>The logged on token.</returns> public static NtToken GetLogonS4UToken(string user, string realm, SecurityLogonType logon_type) { switch (logon_type) { case SecurityLogonType.Batch: case SecurityLogonType.Interactive: case SecurityLogonType.Network: break; default: throw new ArgumentException("Invalid logon type for S4U"); } return(LogonUtils.LogonS4U(user, realm, logon_type)); }