Search

April 2007
M T W T F S S
« Mar   May »
 1
2345678
9101112131415
16171819202122
23242526272829
30  

Map AD property… MOSS 07

April 6th, 2007 by

From: “andyoye” <latitude4uatcommunitydotnospam>
Subject: Map AD property… MOSS 07
Date: Tue, 27 Mar 2007 10:52:27 -0400
Newsgroups: microsoft.public.sharepoint.portalserver

I can use different AD properties mapped to user properties in MOSS07. (like “homeDirecorty”, “exchangeServer”…) But when I select “LogonWrokstation” property, it doesn’t show any info, looks like whatever is visible in AD mmc is available to use. True? any work around?

thanks

**************************************

From: “Mike Walsh” <englantilainenathotmaildotcom>
Subject: Re: Map AD property… MOSS 07
Date: Tue, 27 Mar 2007 20:31:24 +0300
Newsgroups: microsoft.public.sharepoint.portalserver

I’m not surprised. Both homeDirecorty and LogonWrokstation don’t exist.

Mike Walsh
WSS FAQ:
www.wssv3faq.com / wss.collutions.com
No private questions please (additions to FAQ welcome)

**************************************

From: “andyoye”
Subject: Re: Map AD property… MOSS 07
Date: Tue, 27 Mar 2007 14:24:54 -0400
Newsgroups: microsoft.public.sharepoint.portalserver

So it is  absolutely  not possible to map these properties?

**************************************

From: “JJ”
Subject: Re: Map AD property… MOSS 07
Date: Tue, 27 Mar 2007 15:23:01 -0400
Newsgroups: microsoft.public.sharepoint.portalserver

I had a similar problem with the “OU” (organizational unit) field in SPS 2003 – it was available to map, but it never imported anything.

I ended up writing a quick program that did an AD query to get the fields I needed and used the Sharepoint object model to write the values into the profiles.  I run this every night after the built-in profile import via the scheduler to get the fields.

**************************************

From: “andyoye”
Subject: Re: Map AD property… MOSS 07
Date: Wed, 28 Mar 2007 09:28:20 -0400
Newsgroups: microsoft.public.sharepoint.portalserver

Can you post the code of the program you wrote? Is it a Dsquery?

thanks

**************************************

From: “JJ” <jjj@nospam.com>
Subject: Re: Map AD property… MOSS 07
Date: Thu, 29 Mar 2007 09:14:40 -0400
Newsgroups: microsoft.public.sharepoint.portalserver

The code I wrote is below.

I took a look at one of your examples (“logonWorkstation” attribute) and
that may not work even through this code.  I’ve seen info on the web that
either (1) logonWorkstation is an “octet string” and requires special
handling or (2) logonWorkstation is not even used by Windows.  That may be
why MOSS itself cannot import the value. There is also supposed to be an
attribute called “userWorkstations”, but it did not have any values on my
system.

Anyway, good luck…. I hope the code helps.

// Usage is:

//

// UpdateMOSSProfiles

// -d or -domain: specify the AD domain to use [required]

// -s or -server: specify the Sharepoint server [required]

// -a or -adproperty: specify the AD property to write to the user profile
[required]

// -p or -property: specify the User Profile property to update [required]

// -v or -verbose: verbose – display messages as it works, otherwise just
errors

// -t or -testonly: run through but do not actually write to the user’s
profile – good for testing along with -v

// -i or -inactive: include inactive AD users – without, inactive users are
ignored

// -b or -writeblanks: write blank values to the profile – otherwise, blank
AD values are not written

// -q or -query: specify the AD query string to use to override the default

//

// Example: UpdateMOSSProfiles -d MYDOMAIN -s mymoss -a
physicalDeliveryOfficeName -p SPS-Interests

//

// Note: Sharepoint profile property name may be different than what you see
on the screen in Sharepoint

// For example, the “Interests” field is actually internally named
“SPS-Interests”.

// You need to get the string value associated with
PropertyConstants.[Desired Attribute] if you are unsure

//

// Note: Sometimes specifying the FQDN of the Sharepoint server works,
sometimes only the short name works. Don’t know why.

//

// Note: Some AD properties are not strings, and some User Profile
properties are not strings, so this code may need to be modified

// to handle special value types.

//

using System;

using System.Collections.Generic;

using System.Text;

using System.Web;

using System.DirectoryServices;

using System.Xml;

using Microsoft.Office.Server;

using Microsoft.Office.Server.Administration;

using Microsoft.Office.Server.UserProfiles;

using Microsoft.SharePoint;

namespace UpdateMOSSProfiles

{

class Program

{

static void Main(string[] args)

{

string domain = “”;

string sps = “”;

string adQuery = “”;

string adProperty = “”;

string profileProperty = “”;

bool testOnly = false;

bool verbose = false;

bool includeInactive = false;

bool writeBlanks = false;

string account = “”;

string adValue = “”;

int updateCount = 0;

SPSite site = null;

ServerContext context = null;

DirectoryEntry adDirEntry = null;

DirectorySearcher adDirSearch = null;

SearchResultCollection adResults= null;

UserProfileManager profileManager = null;

// Process command line args

if (args.Length > 0)

{

for (int i = 0; i < args.Length; i++)

{

if (args[i] == “-v” || args[i] == “-verbose”)

verbose = true;

else if (args[i] == “-t” || args[i] == “-testonly”)

testOnly = true;

else if (args[i] == “-i” || args[i] == “-inactive”)

includeInactive = true;

else if (args[i] == “-b” || args[i] == “-writeblanks”)

writeBlanks = true;

else if (args[i] == “-d” || args[i] == “-domain”)

{

if (i < args.Length – 1)

domain = args[++i];

}

else if (args[i] == “-s” || args[i] == “-server”)

{

if (i < args.Length – 1)

sps = args[++i];

}

else if (args[i] == “-q” || args[i] == “-query”)

{

if (i < args.Length – 1)

adQuery = args[++i];

}

else if (args[i] == “-a” || args[i] == “-adproperty”)

{

if (i < args.Length – 1)

adProperty = args[++i];

}

else if (args[i] == “-p” || args[i] == “-property”)

{

if (i < args.Length – 1)

profileProperty = args[++i];

}

}

}

// Must specify domain, Sharepoint server, AD property, and User Profile
property

if (domain == “” || sps == “” || adProperty == “” || profileProperty == “”)

{

System.Console.WriteLine(“Usage: UpdateMOSSProfiles [-v|-verbose]
[-t|-testonly] [-i|-inactive] [-b|-writeblanks] [-q|-query ‘AD
query’] -d|-domain DomainName -s|-server SharepointURL -a|-adproperty
ADProperty -p|-property ProfileProperty”);

System.Environment.ExitCode = 1;

return;

}

// Connect to Sharepoint

try

{

if (sps.StartsWith(“http://”,StringComparison.OrdinalIgnoreCase))


site = new SPSite(sps);


else


site = new SPSite(“http://” + sps);


context = ServerContext.GetContext(site);


profileManager = new UserProfileManager(context);


}


catch (Exception ex)


{


Console.WriteLine(“Cannot connect to Sharepoint server ‘” + sps + “‘ – ” +
ex.ToString());


System.Environment.ExitCode = 1;


return;


}


// Connect to Active Directory


try


{


adDirEntry = new DirectoryEntry(“LDAP://dc=” + domain + “,dc=com”);


adDirSearch = new DirectorySearcher(adDirEntry);


adDirSearch.SearchScope = SearchScope.Subtree;


if (adQuery != “”)


adDirSearch.Filter = adQuery;


else


if (includeInactive)


adDirSearch.Filter = “(&(objectCategory=person)(objectClass=user))”;


else


adDirSearch.Filter =
“(&(objectCategory=person)(objectClass=user)(!userAccountControl:1.2.840.113556.1.4.803:=2))”;


adDirSearch.PropertiesToLoad.Add(“sAMAccountName”);


adDirSearch.PropertiesToLoad.Add(“name”);


if (adProperty.ToLower().StartsWith(“ou”))


adDirSearch.PropertiesToLoad.Add(“adspath”);


else


adDirSearch.PropertiesToLoad.Add(adProperty);


adResults = adDirSearch.FindAll();


}


catch (Exception ex)


{


Console.WriteLine(“Cannot connect to Active Directory server ‘” + domain +
“‘ – ” + ex.ToString());


System.Environment.ExitCode = 1;


return;


}


// Iterate through every Active Directory entry


foreach (SearchResult adObject in adResults)


{


adValue = “”;


// Special handling for “ou” – not a “real” AD property


// Can specify just “ou” to get the first OU in the adspath property
(comma-separated string)


// Can specify “ou#” where # is a one-digit number and it will get that OU
value from the string


// For example, “ou2″ will get the second OU= value in the adspath string


if (adProperty.ToLower().StartsWith(“ou”))


{


int whichOU = 1;


int OUCount = 0;


if (adProperty.Length > 2)


if (“123456789″.Contains(adProperty.Substring(2, 1)))


whichOU = Convert.ToInt32(adProperty.Substring(2, 1));


string adpath = adObject.Properties[“adspath”][0].ToString();


string[] adstrings = new string[20];


adstrings = adpath.Split(‘,’);



foreach (string ou in adstrings)


{


if (ou.StartsWith(“OU=”))


{


++OUCount;


if (OUCount == whichOU)


{


adValue = ou.Substring(3);


break;


}


}


}


}


else


{


if (adObject.Properties[adProperty].Count > 0)


adValue = adObject.Properties[adProperty][0].ToString();


}


// Ignore blank values?


if (!writeBlanks && adValue.Trim().Length == 0)


continue;


// Update the profile


account = domain + “\\” +
adObject.Properties[“sAMAccountName”][0].ToString();


try


{


UserProfile u = profileManager.GetUserProfile(account);


if (verbose)


System.Console.WriteLine(adObject.Properties[“sAMAccountName”][0].ToString()
+ “: ” + profileProperty + ” = (” + adProperty + “) ‘” + adValue + “‘”);


if (!testOnly)


{


u[profileProperty].Value = adValue;


u.Commit();


}


++updateCount;


}


catch (UserNotFoundException)


{


Console.WriteLine(“Profile not found for user ” + account);


}


catch (Exception exception)


{


Console.WriteLine(“Error updating user profile for ” + account + ” – ” +
exception.ToString());


}


}


if (verbose)


Console.WriteLine(“{0} profiles updated”, updateCount);



System.Environment.ExitCode = 0;


}


}


}


**************************************


From: v-alxieatonlinedotmicrosofttodcom (Alex Xie [MSFT])
Date: Fri, 30 Mar 2007 08:15:57 GMT
Subject: Re: Map AD property… MOSS 07
Newsgroups: microsoft.public.sharepoint.portalserver


Hi Andy,


Thank you for posting here.


As for this problem, I have also tested on my end and it is by design the logonworkstation information is not mapped to the User profile properties.


I am still performing some research on this and will keep you updated.


In the meantime, you can also take JJ’s advice to develop a program to archive this.


For assistance with this coding issue, you may also consider these resources:


1. MSDN newsgroups for peer experiences and recommendations:


   http://msdn.microsoft.com/newsgroups/default.asp.


2. Public newsgroups for peer experiences and recommendations:


      microsoft.public.sharepoint.develope_and_customization


Thanks & Regards,


Alex Xie
Microsoft Online Partner Support


Get Secure! – www.microsoft.com/security


========================================
PLEASE NOTE:  The partner managed newsgroups are provided to assist with
break/fix issues and simple how to questions. 


We also love to hear your product feedback!
Let us know what you think by posting
 from the web interface: Partner Feedback
 from your newsreader:  microsoft.private.directaccess.partnerfeedback.
We look forward to hearing from you!
========================================
When responding to posts, please “Reply to Group” via your newsreader so
that others may learn and benefit from this issue.
========================================
This posting is provided “AS IS” with no warranties, and confers no rights.


**************************************


From: “andyoye”
Subject: Re: Map AD property… MOSS 07
Date: Fri, 30 Mar 2007 07:42:20 -0400
Newsgroups: microsoft.public.sharepoint.portalserver



Thanks JJ
Alex: I will wait for your update too


**************************************


From: v-alxie@online.microsoft.com (Alex Xie [MSFT])
Date: Fri, 06 Apr 2007 02:35:00 GMT
Subject: Re: Map AD property… MOSS 07
Newsgroups: microsoft.public.sharepoint.portalserver


Hi Andy,


I appreciate your patience.


My research shows that this seems to be a bug in Microsoft Office SharePoint Server 2007. I am sorry for the inconvenience it might bring to you.


I will report this problem to our product team so that this will be archived for our develop team so that they may improve this by an update patch to be released in the near future.


At this point, you may refer to JJ’s codes to develop a program to address this temporarily. Again, we are sorry for the inconvenience.


If you have any further concerns on this, please feel free to post back.


Thanks & Regards,


Alex Xie
Microsoft Online Partner Support


Get Secure! – www.microsoft.com/security


end slug


Posted using BlogJet

Posted in Moss 2007 | No Comments »



Comments are closed.