CreateNetworkAccess
Creates a network application access right.
Syntax
INetworkAccess CreateNetworkAccess ()
Return value
A network application access right for the zone.
Discussion
A network access right enables a user to run an application on a remote computer as another user. For example, a network access right can give a user the ability to run as an SQL Administrator on a remote server.
The right is not stored in Active Directory until you call the Commitmethod.
Example
The following code sample illustrates using the CreateNetworkAccess method in a script:
... // Get the zone object IHierarchicalZone objZone = cims.GetZoneByPath("cn=" + strZone + "," + strContainerDN) as IHierarchicalZone; if (objZone == null) { Console.WriteLine("Zone " + strZone + " does not exist."); } else { INetworkAccess objNetworkAccess = objZone.GetNetworkAccess(strName); if (objNetworkAccess != null) { Console.WriteLine("NetworkAccess " + strName + " already exist."); } else { objNetworkAccess = objZone.CreateNetworkAccess(); objNetworkAccess.Name = strName; objNetworkAccess.RunAsType = WindowsRunAsType.User; objNetworkAccess.Priority = 0; objNetworkAccess.Description = "optional description"; string userPath = DirectoryServices.GetLdapPathFromDN(cims.Server, strUser); DirectoryEntry userEntry = DirectoryServices.GetDirectoryEntry(userPath, cims.UserName, cims.Password); SecurityIdentifier m_userSid = new SecurityIdentifier(DirectoryServices.GetStringSid(userEntry)); objNetworkAccess.RunAsList = new List<SecurityIdentifier> { m_userSid }; objNetworkAccess.Commit(); Console.WriteLine("NetworkAccess " + strName + " is created successfully."); } } ...