I would like to enable/disable logonHours for particular user by using Web api 2.0 ,tried with code, everything is working fine set/get other than that logonHours, please help me out.
DirectoryEntry("LDAP://test.com","Administrator", "tesT.123$")) {
using (DirectorySearcher objAdSearcher = new DirectorySearcher(objRootEntry))
{
objAdSearcher.Filter = "(&(objectClass=user)(samAccountName=" + username + "))";
SearchResult objResult = objAdSearcher.FindOne();
if (objResult != null)
{
objResult.GetDirectoryEntry().Properties["title"].Value = "Test"; //its working fine.
byte[] logonHours = new byte[] { 0, 0, 0, 0, 0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, 0 };
//byte[] logonHours = new byte[] {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 };
objResult.GetDirectoryEntry().Properties["logonHours"].Value = logonHours; //its not working, also not throwing any error
objResult.GetDirectoryEntry().CommitChanges();
}
}
}
Thanks in advance
Aucun commentaire:
Enregistrer un commentaire