GetAccountAttribute() public static method

get specified attribute of an account
public static GetAccountAttribute ( string accountName, string accountType, string attributeName, string domainName, string domainAdminName, string domainAdminPwd ) : string
accountName string
accountType string
attributeName string
domainName string
domainAdminName string
domainAdminPwd string
return string
示例#1
0
        private void AddOtherService(ref ResultItemMap resultMap, string computerName, OtherService service, DomainInfo domain)
        {
            try
            {
                ServerHelper.GetAccountAttribute(computerName, "Computers", "sAMAccountName", domain.Name, domain.Admin, domain.AdminPassword);

                if (!string.IsNullOrEmpty(service.FQDN))
                {
                    AddResultItem(ref resultMap, computerName + " FQDN: ", service.FQDN, DetectResult.Supported);
                }
                if (!string.IsNullOrEmpty(service.NetBios))
                {
                    AddResultItem(ref resultMap, computerName + " NetBios: ", service.NetBios, DetectResult.Supported);
                }
                if (!string.IsNullOrEmpty(service.Password))
                {
                    AddResultItem(ref resultMap, computerName + " Password: "******" DefaultServiceName: ", service.DefaultServiceName, DetectResult.Supported);
                }
                if (!string.IsNullOrEmpty(service.ServiceSalt))
                {
                    AddResultItem(ref resultMap, computerName + " ServiceSalt: ", service.ServiceSalt, DetectResult.Supported);
                }
            }
            catch
            {
                if (!string.IsNullOrEmpty(service.FQDN))
                {
                    AddResultItem(ref resultMap, computerName + " FQDN: ", service.FQDN, DetectResult.UnSupported);
                }
                if (!string.IsNullOrEmpty(service.NetBios))
                {
                    AddResultItem(ref resultMap, computerName + " NetBios: ", service.NetBios, DetectResult.UnSupported);
                }
                if (!string.IsNullOrEmpty(service.Password))
                {
                    AddResultItem(ref resultMap, computerName + " Password: "******" DefaultServiceName: ", service.DefaultServiceName, DetectResult.UnSupported);
                }
                if (!string.IsNullOrEmpty(service.ServiceSalt))
                {
                    AddResultItem(ref resultMap, computerName + " ServiceSalt: ", service.ServiceSalt, DetectResult.UnSupported);
                }
            }
        }
示例#2
0
        private void AddUserList(ref ResultItemMap resultMap, Dictionary <string, User> users, DomainInfo domain)
        {
            foreach (string key in users.Keys)
            {
                User user = users[key];
                try
                {
                    //detect the user in domain
                    //if cannot get the user information, set unsupported result.

                    string userName = ServerHelper.GetAccountAttribute(user.Name, "Users", "sAMAccountName", domain.Name, domain.Admin, domain.AdminPassword);

                    if (string.IsNullOrEmpty(userName))
                    {
                        AddResultItem(ref resultMap, key + " User Name: ", user.Name, DetectResult.UnSupported);

                        //cannot detect the password, assume the default value
                        AddResultItem(ref resultMap, key + " User Password: "******" User Salt: ", user.Salt, DetectResult.UnSupported);
                        }
                    }
                    else
                    {
                        AddResultItem(ref resultMap, key + " User Name: ", user.Name, DetectResult.Supported);
                        AddResultItem(ref resultMap, key + " User Password: "******" User Salt: ", user.Salt, DetectResult.Supported);
                        }
                    }
                }
                catch
                {
                    AddResultItem(ref resultMap, key + " User Name: ", "", DetectResult.DetectFail);
                    AddResultItem(ref resultMap, key + " User Password: "******"", DetectResult.DetectFail);
                }

                try
                {
                    string spn = ServerHelper.GetAccountAttribute(user.Name, "Users", "servicePrincipalName", domain.Name, domain.Admin, domain.AdminPassword);
                    if (user.ServiceName != null)
                    {
                        if (!string.IsNullOrEmpty(spn))
                        {
                            user.ServiceName = spn;
                            AddResultItem(ref resultMap, key + " User ServiceName: ", user.ServiceName, DetectResult.Supported);
                        }
                        else
                        {
                            AddResultItem(ref resultMap, key + " User ServiceName: ", user.ServiceName, DetectResult.UnSupported);
                        }
                    }
                }
                catch
                {
                    if (user.ServiceName != null)
                    {
                        AddResultItem(ref resultMap, key + " User ServiceName: ", "", DetectResult.DetectFail);
                    }
                }
            }
        }