Showing posts with label Windows. Show all posts
Showing posts with label Windows. Show all posts

Wednesday, April 17, 2013

Allow Remote WMI connection in Windows Servers 2008 R2

I wanna a C# program to get disk space of a remote server whose OS is Windows Server 2008 R2. The program and the server are under different domains. I use server's domain account to authenticate the connection. 

Unluckily, the most different part of this task is the configuration of enabling remote WMI connection, not the program to get a disk space. Two error codes:  

=> The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)  
=> Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))  

I have spent much time on the first one and it seems there are some thing wrong with my config. Here are some steps I still remember:

1. Allow WMI to communicate through firewall



2. Enable "remote launch" and "remote activation" in Access Permission of Component Services



3. Enable "remote access" in Access Permission of Component Services



4. Enable "remote enable" in WMI Control Properties



You can simply test WMI connection by using wmic command
wmic /node:localhost /user:administrator /password:1234 bios get serialnumber 

Wednesday, September 5, 2012

Verify Local Windows Account Password

I would like to verify local windows account and password through a web part in SharePoint 2010. The code snippet is show below:

protected bool verifyUserAccount(string computerName, string userName, string password)
{
    bool flag = false;
    using (PrincipalContext context = new PrincipalContext(ContextType.Machine, computerName, userName, password))
    {
        flag = context.ValidateCredentials(userName, password);
    }
    return flag;
}

Then the above snippet can really verify local windows account and password!






Wednesday, August 22, 2012

Update Windows Local Account Password

I would like to enable users to update their account passwords through a Web Part in SharePoint 2010.

using System.DirectoryServices;
using System.DirectoryServices.AccountManagement;

string userPath = "WinNT://computerName/userName";
DirectoryEntry userEntry = new DirectoryEntry(userPath);
object[] password = {newPassword};
object ret = userEntry.Invoke("SetPassword", password);
userEntry.CommitChanges();

userEntry.Close();

Above snippet code can really update their passwords!

Change local administrator password in C# 

Tuesday, March 13, 2012

Setting NFS Client in Windows 7

I need to map a network drive to a NFS Server in CentOS 5.5 and the steps are shown below:

 1. Go to Control Panel => Programs and Features => Turn Windows features on or off and enable Services for NFS

 2. If you want to connect to NFS as root, go to regedit and edit HKKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default\RegNotify.

     AnonymousGid: root
     AnonymousUid: root

3. Restart service of "Client for NFS"

4. Map network drive

Tuesday, May 10, 2011

Cannot edit DCOM Config properties

I get an error from my event handler which suggests me to modify  the {000C101C-0000-0000-C000-000000000046} using the Component Services administrative Tool.

1. Administrative Tools ->  Component Services -> {000C101C-0000-0000-C000-000000000046}
2. Right click the {000C101C-0000-0000-C000-000000000046} and then select properties
3. Go to security tab and I cannot edit the "Launch and Activation Permission" and "Access Permissions" ad the choices are grayed out

After another searching, I know that I need to do something in Register Editor

1.  In cmd, type "regedit"
2. Go to HK_LOCAL_MACHINE\SOFTWARE\Classes\AppID\{000C101C-0000-0000-C000-000000000046}
3. Right click it and select permission and then click Adanced
4. Go to Owner tab and update Administrators ad the current Owner


5. Grant the administrators "Full Control"

6. Restart the Component Services

7. You can modify the Permissions now