Question : LDAP/ Active Directory  Password Unlock Error..

DirectoryEntry de = GetDirectoryEntry();

                DirectorySearcher searcher = new DirectorySearcher(de);

                searcher.Filter = "(CN=" + cn + ")";
             
                searcher.CacheResults = false;

                SearchResult result = searcher.FindOne();

                de = result.GetDirectoryEntry();

                de.Properties["LockOutTime"].Value = 0x0000;

// It gives null reference exception when i try to commit.. (Object reference not set to instance of an object..)

                de.CommitChanges();

Answer : LDAP/ Active Directory  Password Unlock Error..

Here is a version of your code that works

            DirectoryEntry de = new DirectoryEntry("LDAP://CN=Users,DC=xxx,DC=com");

            DirectorySearcher searcher = new DirectorySearcher(de);
            searcher.Filter = "(CN=" + "gautam reddyc" + ")";
            searcher.CacheResults = false;
            SearchResult result = searcher.FindOne();

            de = result.GetDirectoryEntry();
            de.Properties["LockOutTime"].Value = 0x0000;
            de.CommitChanges();
Random Solutions  
 
programming4us programming4us