/// <summary> /// Open dos devices directory for current effective token. /// </summary> /// <returns>The directory object</returns> /// <exception cref="NtException">Thrown on error</exception> public static NtDirectory OpenDosDevicesDirectory() { using (NtToken token = NtToken.OpenEffectiveToken()) { return(OpenDosDevicesDirectory(token)); } }
private NtToken GetToken() { if (Token?.IsPseudoToken ?? false) { return(Token); } return(Token?.Duplicate() ?? NtToken.OpenEffectiveToken()); }
private NtToken GetToken() { if (Token != null) { return(Token.Duplicate()); } return(NtToken.OpenEffectiveToken(NtThread.Current, true, false, TokenAccessRights.AdjustDefault)); }
private NtToken GetToken() { if (Token != null) { return(Token.Duplicate(TokenAccessRights.Query)); } return(NtToken.OpenEffectiveToken()); }
/// <summary> /// Overridden BeginProcessing. /// </summary> protected override void BeginProcessing() { if (OpenForBackup) { using (var token = NtToken.OpenEffectiveToken()) { if (!token.SetPrivilege(TokenPrivilegeValue.SeBackupPrivilege, PrivilegeAttributes.Enabled)) { WriteWarning("OpenForBackup specified but caller doesn't have SeBackupPrivilege"); } } } base.BeginProcessing(); }
private NtToken GetToken() { if (Token != null) { return(Token.DuplicateToken(TokenType.Impersonation, SecurityImpersonationLevel.Identification, TokenAccessRights.Query)); } else { using (NtToken token = NtToken.OpenEffectiveToken()) { return(token.DuplicateToken(TokenType.Impersonation, SecurityImpersonationLevel.Identification, TokenAccessRights.Query)); } } }
/// <summary> /// Overridden ProcessRecord method. /// </summary> protected override void ProcessRecord() { if (MapGeneric && Type == null) { WriteWarning("Must specify Type for MapGeneric to work correctly."); } SecurityDescriptor sd; switch (ParameterSetName) { case "FromToken": { Type = Type ?? Parent?.NtType ?? Creator?.NtType; if (Type == null) { WriteWarning("Security descriptor type not specified, defaulting to File."); Type = NtType.GetTypeByType <NtFile>(); } using (var list = new DisposableList()) { if (EffectiveToken) { Token = list.AddResource(NtToken.OpenEffectiveToken()); } sd = SecurityDescriptor.Create(Parent, Creator, ObjectType, Container, AutoInherit, Token, Type.GenericMapping); } } break; case "FromSddl": sd = new SecurityDescriptor(Sddl); break; case "FromBytes": sd = new SecurityDescriptor(Byte); break; case "FromKey": sd = new SecurityDescriptor(Key.QueryValue(ValueName).Data); break; case "FromKeyValue": sd = new SecurityDescriptor(KeyValue.Data); break; case "FromBase64": sd = SecurityDescriptor.ParseBase64(Base64); break; default: sd = CreateNewSecurityDescriptor(); break; } sd.NtType = Type; sd.Container = Container; if (MapGeneric) { sd.MapGenericAccess(); } sd.Control |= Control; WriteObject(sd); }