Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

read administrator account remote machine C#

static bool isAdmin(string username, string machinename)
{
    using (PrincipalContext ctxMacine = new PrincipalContext(ContextType.Machine, machinename))
    {
        using (PrincipalContext ctxDomain = new PrincipalContext(ContextType.Domain))
        {
            UserPrincipal up = UserPrincipal.FindByIdentity(ctxDomain, IdentityType.SamAccountName, username);
            GroupPrincipal gp = GroupPrincipal.FindByIdentity(ctxMacine, "Administrators");

            foreach (UserPrincipal usr in gp.GetMembers(true))
            {
                if (up != null)
                {
                    if (up.SamAccountName.ToUpper() == usr.SamAccountName.ToUpper())
                    {
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# udpclient receive buffer size 
Csharp :: come controllare se textbox è vuota c# 
Csharp :: how to show error xtramessagebox in devexpress c# 
Csharp :: como guardar archivo en un botón asp.net 
Csharp :: .net directorysearcher get manager accountname 
Csharp :: string to date 
Html :: trademark symbol 
Html :: input tag no suggestions 
Html :: starter data jpa maven dependency 
Html :: htmjl favicons 
Html :: regex href html pattern 
Html :: font awesome linkedin 
Html :: centralize div bootstrap 
Html :: pattern for email id in html 
Html :: html character tab 
Html :: add title logo html 
Html :: html head logo 
Html :: jquery integration 
Html :: input readonly html 
Html :: stop video javascript 
Html :: favicon for html page 
Html :: twig foreach key value 
Html :: html estrutura 
Html :: html textarea 
Html :: bootstarp btn colors 
Html :: youtube embed autoplay 
Html :: fav icon html 
Html :: autocomplete html off 
Html :: how to center the mainin html 
Html :: react bootstrap navbar fixed 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =