K2.ProcessInstance.Originator.Name returns NT Login name.

  • 3 November 2006
  • 5 replies
  • 7 views

Badge +8
I assume you want to display the user's displayname in the email?

K2.ProcessInstance.Originator.Name will always return the user's AD login name (domainusername), there is no configuration setting to change this behaviour.

If you have the user's login name, you can use the DirectoryServices .NET namespace to pass a query to AD to return the user's displayname. The following code snippet is an example of how to do this:

.ToString();
}
else
displayName = "";
}
return displayName;
}
}


you will need to decide when you want to retrieve the user's displayname - you could capture it as part of process instance data when the user starts the process, or you can use code within a K2 server event to retrieve the user's displayname.

If you are using a server event, there is a neat trick to get the LDAP path that has been set in the K2Server.config file, as the following code snippet demonstrates:


string adPath = "";
SourceCode.K2Utilities.DSHelper ds = new SourceCode.K2Utilities.DSHelper((SourceCode.K2Utilities.DSHelper.DSHelperNewOptionsEnum)0);
adPath = @"LDAP://" + ds.GetDefaultLDAPDomain();


You can then pass this ADPath to the DirectoryEntry object in the previous code snippet.

Hope this helps

5 replies

Badge +4
Hi All,

I am using K2.ProcessInstance.Originator.Name in few email msg s but realized that NT login name is displayed instead of User Name.
Do I need to do any settings?

Pls advice.

Siva
Badge +6
Hi Siva,

I am not sure by hat you mean with NT login, but where is the process started from? If it is an ASPX page then you need to enable impersonation in the web.config file of the web application.

<identity impersonate="true"/>

Also, make sure to disable Anonymous access on the web application.

Hope this helps,
Conrad
Badge +6
Oops - yes thats correct...
Badge +4
thanks for ur response...

I was under the impression that K2.ProcessInstance.Originator.Name will return display name of the user.

Siva
Badge +13
This should get you the full name.

Dim oDSH As New SourceCode.K2Utilities.DSHelper()
Dim oDE As System.DirectoryServices.DirectoryEntry

oDE = DSH.GetUser(K2.ProcessInstance.Originator.Name).Path
If Not oDE Is Nothing Then
sDisplayName = oDE.Properties("displayName")(0).ToString
End If

Somehow oDE.UserName returns blank.

Reply