Browsed by
Month: October 2013

Extended Active Directory Attributes from Orchestrator

Extended Active Directory Attributes from Orchestrator

ADExtPublic OIP download

So we have just implemented a new VoIP Phone system and we found that on occasion we would get errors where disabled users object would still have the ipPhone attribute populated with a number that had been reassigned. To report back on this is pretty simple by using the SCCM user object discovery, but to how do we automate a solution to do something with the details. We ended up settling on using System Centre Orchestrator, as it allows us to be a little bit more flexible then a script.

So I got to work creating an OIP, and in the end I created 3 custom Activities, which are “”, “” and “” detailed below.

Obtain Custom Properties:

This one is quite simple in its use, you define the String Attibute for the user object that you want returned and it will return it.
Inputs:

Distinguished Name:  This is the Distinguished Name of the user.
Property Name: This is the name of the Attribute that you want returned.

Outputs:

Property result: This is the Value of the Attribute for the desired user.

Obtain ipPhone:

The result of this activity is the same as the Obtain Custom Properties activity, just hard set to the ipPhone attribute.

Inputs:

Distinguished Name:  This is the Distinguished Name of the user.

Outputs:

ipPhone: This is the Value of the ipPhone attribute for the desired user.

Remove ipPhone:

This Activity is a little more destructive, it will actually clear the ipPhone attribute for the defined user object.

Inputs:

Distinguished Name:  This is the Distinguished Name of the user.

Outputs:

IPPhone removal result: Result of “Success” or “did not exist”

As you can see below the scripts for this OIP is pretty simple.

ADUserExtended.cs

using Microsoft.SystemCenter.Orchestrator.Integration;namespace ADUserExtended
{
[Activity(“Obtain Custom Properties”)]
public class ADExtendedCustProp
{
private string usercust;
[ActivityInput(“Distingished Name”)]
public string Usercust
{
set { usercust = value; }
}
private string propname;
[ActivityInput(“Property Name”)]
public string Propname
{
set { propname = value; }
}
[ActivityOutput(“Property result”)]
public string PropResult
{
get { return defineProp.getcustprop(usercust, propname); }
}
}
[Activity(“Obtain ipPhone”)]
public class ADExtendedipPhone
{
private string userip;
[ActivityInput(“Distingished Name”)]
public string Userip
{
set
{
userip = value;
}
}
[ActivityOutput(“ipPhone”)]
public string IPPhone
{
get { return checkphone.GetIPphone(userip); }
}
}
[Activity(“Remove ipPhone”)]
public class ADExtendedremove
{
private string userrem;
[ActivityInput(“Distingished Name”)]
public string Userrem
{
set
{
userrem = value;
}
}
[ActivityOutput(“IPPhone removal result”)]
public string IPPhonerem
{
get { return removeipPhone.remIPphone(userrem); }
}
}
}

 DefineProps.cs

using System.DirectoryServices;namespace ADUserExtended
{
class defineProp
{
public static string getcustprop(string userId, string Propname)
{
using (var userEntry = new DirectoryEntry(@”LDAP://” + userId))
{
if (userEntry.Properties.Contains(Propname))
{
return userEntry.Properties[Propname][0].ToString();
}
else
{
return “did not exist”;
}
}
}
}
}

CheckPhones.cs

using System.DirectoryServices;namespace ADUserExtended
{
public class checkphone
{
public static string GetIPphone(string userId)
{
using (var userEntry = new DirectoryEntry(@”LDAP://” + userId))
{
if (userEntry.Properties.Contains(“ipPhone”))
{
return userEntry.Properties[“ipPhone”][0].ToString();
}
else
{
return string.Empty;
}
}
}
}
}

RemoveipPhone.cs

using System.DirectoryServices;namespace ADUserExtended
{
class removeipPhone
{
public static string remIPphone(string userId)
{
using (var userEntry = new DirectoryEntry(@”LDAP://” + userId))
{
if (userEntry.Properties.Contains(“ipPhone”))
{
userEntry.Properties[“ipPhone”].Clear();
userEntry.CommitChanges();
userEntry.Close();
return “success”;
}
else
{
return “did not exist”;
}
}
}
}
}

Good Luck

Steve