Csharp/CSharp Tutorial/Directory Services/Modify — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 15:31, 26 мая 2010
Modifying Existing Object Attributes
using System;
using System.DirectoryServices;
public class MainClass
{
public static int Main(string[] args)
{
DirectoryEntry MyDirectoryObject = new DirectoryEntry();
MyDirectoryObject.Path = "LDAP://HMSRevenge/CN=Greg MacBeth,OU=users,DC=Test,DC=com";
MyDirectoryObject.Username = @"Test\tttt";
MyDirectoryObject.Password = @"MyPassword";
if(MyDirectoryObject.Properties[("company")].Value == "Old Company Name. inc.")
{
MyDirectoryObject.Properties[("company")][0] = "new name";
}
MyDirectoryObject.rumitChanges();
return 0;
}
}
Modify Property
using System;
using System.DirectoryServices;
class MainClass
{
public static void Main()
{
DirectoryEntry de = new DirectoryEntry(
"LDAP://192.168.1.100/cn=kblum, ou=sales, dc=ispnet1, dc=net",
"cn=Administrator, dc=ispnet1, dc=net", "password",
AuthenticationTypes.ServerBind);
de.Properties["sn"][0] = "new Value";
de.rumitChanges();
Console.WriteLine("New property value: {0}", de.Properties["sn"][0]);
de.Close();
}
}