protected override void ProcessRecord() { List <SmoLogin> logins = SmoLogin.GetLogins(_server); this.FilterByLoginNameOrSid(ref logins); this.FilterByLoginId(ref logins); this.FilterByType(ref logins); WriteObject(logins, true); }
protected override void ProcessRecord() { SmoLogin login = base.CreateLogin(this.LoginName, LoginType.SqlLogin, this.DefaultDatabase, this.Password, this.PasswordExpirationEnabled.ToBool(), this.PasswordPolicyEnabled.ToBool()); if (login != null) { base.WriteObject(login); } }
protected private bool GetLoginFromName(string loginName, out SmoLogin outLogin) { bool contains = _server.Logins.Contains(loginName); outLogin = null; if (contains) { outLogin = _server.Logins[loginName]; } return(contains); }
private void FilterByLoginId(ref List <SmoLogin> logins) { if (this.Identity != null && this.Identity.IsID) { for (int i = logins.Count - 1; i >= 0; i--) { SmoLogin l = logins[i]; if (!l.ID.Equals((int)this.Identity)) { logins.Remove(l); } } } }
private void FilterByType(ref List <SmoLogin> logins) { //if (this.MyInvocation.BoundParameters.ContainsKey("Type")) if (this.Type != null && this.Type.Length > 0) { for (int i = logins.Count - 1; i >= 0; i--) { SmoLogin l = logins[i]; if (!this.Type.Contains(l.LoginType)) { logins.Remove(l); } } } }
private void FilterByLoginNameOrSid(ref List <SmoLogin> logins) { if (this.Identity != null && (this.Identity.IsLoginName || this.Identity.IsSecurityIdentitifer)) { var wcp = new WildcardPattern((string)this.Identity, WildcardOptions.IgnoreCase); for (int i = logins.Count - 1; i >= 0; i--) { SmoLogin smol = logins[i]; if (!wcp.IsMatch(smol.Name) && !wcp.IsMatch(smol.Sid)) { logins.Remove(smol); } } } }
protected override void ProcessRecord() { if (this.MyInvocation.PipelinePosition > 1) { oneTimeNB = true; } if (!this.LoginName.FromADObject && !this.IsLocalUser && !this.IsLocalGroup) { this.ConditionOne(); } else if (this.IsLocalUser) { this.LoginName.Type = LoginType.WindowsUser; this.LoginName.IsLocal = true; this.LoginName.NetBiosName = _server.NetName; } else if (this.IsLocalGroup) { this.LoginName.Type = LoginType.WindowsGroup; this.LoginName.IsLocal = true; this.LoginName.NetBiosName = _server.NetName; } if (!this.LoginName.Type.HasValue) { throw new ArgumentException("Could not determine what kind of Windows user this was."); } string login = this.GetLoginName(this.LoginName); SmoLogin smol = base.CreateLogin(login, this.LoginName.Type.Value, this.DefaultDatabase); if (smol != null) { WriteObject(smol); } }
protected private SqlProcessCollection FindProcess(SmoLogin login) => SqlProcessCollection.GetProcesses(login.Name, _server);