Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
            }
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
 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);
             }
         }
     }
 }
Esempio n. 5
0
 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);
             }
         }
     }
 }
Esempio n. 6
0
 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);
             }
         }
     }
 }
Esempio n. 7
0
        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);
            }
        }
Esempio n. 8
0
 protected private SqlProcessCollection FindProcess(SmoLogin login) => SqlProcessCollection.GetProcesses(login.Name, _server);